Your compiler should warn you about the use of an uninitialized local.
If you are using gcc, then kick up the warning level with:
gcc -Wall -Wextra -Wpedantic ...
Code:
#include <stdio.h>
 
int x; // uninitialized global variables start all-bits zero
 
void f() {
    static int y; // uninitialized static variables start all-bits zero
    int z; // local variables are lucky-dip
    printf("%d %d %d\n", x, y, z);
}
 
void g() {
    // This will fill the stack frame with some values.
    int a = 1, b = 2, c = 3;
    printf("%d %d %d\n", a, b, c);
}
 
int main() {
    f(); // before g fills the stack frame
    g();
    f(); // after g fills the stack frame
         // may or may not make a difference
         // ultimate result can even depend on optimization level
    return 0;
}