0 votes 0 votes what is the reason…..?for error.. Programming in C programming-in-c programming + – shiva0 asked Jan 22, 2019 shiva0 305 views answer comment Share Follow See all 4 Comments See all 4 4 Comments reply prashant jha 1 commented Jan 22, 2019 reply Follow Share sizeof(p) ? What is p here? 0 votes 0 votes shiva0 commented Jan 22, 2019 reply Follow Share am also confusing about p. I got this from geeksfrom geeks 0 votes 0 votes OneZero commented Jan 22, 2019 reply Follow Share Malloc allocates memory at runtime( dynamically). whereas static allocates memory at compile time itself. You are giving contradicting memory allocation methods. hence the error. 0 votes 0 votes shiva0 commented Jan 22, 2019 i edited by shiva0 Jan 22, 2019 reply Follow Share But it is working in c++ and in the link proveded above is saying that the error is because of initializing global and static variables must be constant not expression.am thinking that the error is about the the initialization.can you tell me which one is correct...... OneZero what is p in sizeof(p) 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes during initialization itself you are using p and also assignment operator has right assosiativity so it finds what is this p If you do static int*p; p=(int *) malloc(sizeof(p)) then its working kd..... answered Jan 23, 2019 kd..... comment Share Follow See all 0 reply Please log in or register to add a comment.