So the function "thinkOfANumber" gives the variable "x" the value 108. Then, we go in to the function "mindReading" that has the variable "secrets" which isn't given any value. But somehow it get the same value as "x". My guess is that it has something to do with the stack and memory. Could someone explain it for me?
The code:
void thinkOfANumber(){
int x = 108;
printf( "This function thinks of a secret number (%d)\n", x);
}
void mindReading(){
int secret;
printf( "This function believes that the other functions secret is: %d!\n", secret); //Prints 108
}
void main(){
thinkOfANumber();
mindReading();
return 0;
}