memory allocation for struct in c++
How do we allocate memory of struct?
what i did was Code:
int main() In funtion 'int main()': error: expected primary-expression before 'struct' error: expected ';' before 'struct' Please help me with this.. i tried looking it on net but could not find it.. |
memory allocation for struct in c++
How do we allocate memory of struct?
what i did was Code:
int main() In funtion 'int main()': error: expected primary-expression before 'struct' error: expected ';' before 'struct' Please help me with this.. i tried looking it on net but could not find it.. |
Why would you do something perverse like mix cout (C++) with "malloc()" ;)?
Anyway, the problem is mixing a declaration ("struct amp*s) in with an expression. You have several alternatives: Code:
struct amp Code:
struct amp Code:
struct amp |
memory location
Thanks for the code.
but my problem was on memory location, that is my second part struct amp*s = malloc(sizeof(struct amp)). please help me with this. Thanks again. Quote:
|
Hi -
Just like deja vu all over again ;) Anyway, the problem is mixing a declaration ("struct amp*s) in with an expression. You have several alternatives: Code:
struct amp Code:
struct amp Code:
struct amp |
I have merged your 2 duplicate threads---next time, only one thread per topic---thanks
|
i am not getting it.. i just wanna know where is struct located.. please help me with finding how to find the memory location OF struct.
|
Quote:
Otherwise you can find the address by using the & operator. Why do you want to find the memory location of struct? |
Hi -
Graemef is absolutely correct: Quote:
Code:
#include <stdio.h> |
You cannot declare there.
Quote:
|
All times are GMT -5. The time now is 04:17 PM. |