+ 1
If we don't assign any value in the 'int' and the 'float' data type, automatically these data types put this value as 0 , WHY?
also want to know that, Why in the same case , double assign the value as 8 in %d specifier but in other specifiers this value is as the same and that is 0 .I want to know about this matter very easily.
1 Odpowiedź
+ 5
In C, not assigning a value to an int does not guarantee it to be 0! The C standard says that the value will be *undefined*, so it can be anything, and you must always set it yourself.
When I run
int main(){
int i;
printf("%d", i);
}
on my computer, I get "4194432". So there's that.