-
March 4th, 2011, 10:48 AM
#1
a simple basic question...
hello every1..
m a newbie to programming and am seeking help for this simple question i have...
#include<stdio.h>
main()
{
int a;
printf("%d",a);
}
the output for the above program gives me something as 19345234...
the value being displayed here is the location of the memory? or simply some garbage value tat already occupies the memory block from before...?
wat should i add to this program so that the output displayed is null...?
-
March 4th, 2011, 10:51 AM
#2
Re: a simple basic question...
You haven't assigned any value to a, so the value of a is undefined when you print it.
-
March 4th, 2011, 11:04 AM
#3
Re: a simple basic question...
yea fine... i accept tat too... but wat is the value tat is being diplayed here?
-
March 4th, 2011, 11:11 AM
#4
Re: a simple basic question...
It's the value of the variable a. a is located on the stack. Since you haven't assigned anything to it, whatever bits happened to be set in that location are interpreted as an int and printed.
-
March 4th, 2011, 11:12 AM
#5
Re: a simple basic question...
Originally Posted by xen_
yea fine... i accept tat too... but wat is the value tat is being diplayed here?
You need to get the h key on your keyboard checked.
-
March 4th, 2011, 11:12 AM
#6
Re: a simple basic question...
Tat vaL is like rite woteva, ya now? its like wot was in dat like space wen u md yr like a
-
March 4th, 2011, 11:17 AM
#7
Re: a simple basic question...
hmmm... i get it nw... thxx a lot...
wt shud i add here so as to free up the memory?
realloc() should work?
-
March 4th, 2011, 11:34 AM
#8
Re: a simple basic question...
You aren't doing any manual memory management here. There's nothing to clean up.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|