LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Blogs
User Name
Password

Notices

Old

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()':
...
LQ Newbie
Posted in Uncategorized
Views 650 Comments 1 amused is offline

  



All times are GMT -5. The time now is 01:31 AM.

Main Menu
Advertisement

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