It is currently Wed Jul 06, 2011 8:20 pm

All times are UTC - 8 hours




 Page 1 of 1 [ 2 posts ] 
Author Message
 Post subject: malloc?
PostPosted: Fri Feb 18, 2011 3:44 pm 

Joined: Fri Feb 18, 2011 3:41 pm
Posts: 6
Does malloc not work?

    char *x = malloc(1);
    printf("TEST: x=%p\n", x);


...always outputs 0x00000000. :cry:


Offline
 Profile  
 
 Post subject: Re: malloc?
PostPosted: Fri Feb 18, 2011 5:08 pm 
User avatar

Joined: Tue Feb 15, 2011 1:00 am
Posts: 60
It does not.

You'll have to initialize any memory you want to use yourself. Your code could be re-written:

char x;
printf("TEST: x=%p\n", &x);

Many of the examples posted use text buffers to store data. Take a look at those.


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 2 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: