LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 1159 Comments 1 amused is offline

  



All times are GMT -5. The time now is 06:46 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration