I decided to rewrite what I was doing going backwards to basics:
#include <stdio.h>
int main () {
int a;
int b;
int c;
int d;
printf("ta-dah: %i %i %i %i\n", a, b, c, d);
return 0;
}
I call it me.c and I compile it with gcc me.c and run it with ./a.out.
I get this as a result:
hc$ ./a.out
ta-dah: 32767 1477090280 0 0
This is a very simple program, and I am not sure where the error is. Any suggestions?
Non-static variables (local variables) are indeterminate. Reading them prior to assigning a value results in undefined behavior.
Either initialize the variables:
Output:
ta-dah: 1 2 3 4Or set them to static:
Output:
ta-dah: 0 0 0 0