Le code suivant génère y est la réponse, mais je n'ai jamais assigné 42 à y, comment pourrait-il être 42?La variable non affectée a une valeur
#include <stdio.h>
void doit2(void)
{
int x;
int y;
if (x == 42)
{
printf("x is the answer\n");
}
else if (y == 42)
{
printf("y is the answer\n");
}
else
{
printf("there is no answer\n");
}
}
void doit1(int a)
{
int b = a;
}
int main(void)
{
doit1(42);
doit2();
}
Vous devriez demander "comment pourrait-il * pas * être 42"? –
Qu'attendez-vous de y? – recursive
Dupliquer: http://stackoverflow.com/questions/1225788/uninitialized-values-being-initialized/1225790 – GManNickG