Следующий код генерирует y, это ответ, но я никогда не назначал 42 на y, как может быть 42?Неназначенная переменная имеет значение
#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();
}
Вы должны спросить «как это могло бы быть не * 42»? –
Что вы ожидаете от y? – recursive
Duplicate: http://stackoverflow.com/questions/1225788/uninitialized-values-being-initialized/1225790 – GManNickG