LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Blogs > amused
User Name
Password

Notices

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

Code:
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 616 Comments 1
« Prev     Main     Next »
Total Comments 1

Comments

  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:09 AM.

Main Menu

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