Possible Duplicate:
initial value of int array in C
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
char name[10];
printf("%s\n", name);
return 0;
}
What value does an uninitialized string in C hold ? Does the compiler automatically allocate a storage of size 10 and fill it with garbage values ? What basically happens on writing the above code ?
10 bytes are allocated on the stack, that's all. Their value is left as is, that means it is what ever had been written to such 10 bytes before having been allocated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With