Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Blogs > amused
User Name


Rate this Entry

memory allocation

Posted 03-30-2010 at 12:01 AM by amused

How do we allocate memory of struct?

what i did was

int main()
struct amp
    string z;
    char y;
    float x;
    int w;

cout <<"The size of 'struct' is"<< sizeof(struct amp)<<"and it is located at"<<struct amp*s = malloc(sizeof(struct amp))<<endl;
it gives me an error---

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..
Posted in Uncategorized
Views 818 Comments 1
« Prev     Main     Next »
Total Comments 1


  1. Old Comment
    Why don't you ask in the programming forum here?
    Posted 03-30-2010 at 06:27 AM by brianL brianL is offline


All times are GMT -5. The time now is 12:59 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration