dev c++ - Automatic variable in C not initialized but given fixed value within loop -


i read automatic variables in c, if not initialized values, contain garbage values. however, found did not correspond understanding. consider following piece of code.

#include <stdio.h>  main()  {     int = 0;      (i = 0 ; i< 10; i++)     {            int x;         int = 500;         printf("%d\t%d\n", a, x);      } } 

output:

500     2 500     2 500     2 500     2 500     2 500     2 500     2 500     2 500     2 500     2 

my question - shouldn't expecting garbage values instead of 2s? ran program on dev-c++ on windows machine.

uninitialized means declared not set definite known value before used.

it have value, not predictable one.in case 2. on other system may else.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -