The storage duration of both variable patty
and tim
is automatic.
Variable patty
and tim
are same in terms of storage duration but results may be different when you try to access them because one is initialized and other is not and accessing an uninitialized object with automatic storage duration is undefined behavior:
int patty; //Uninitialized
int tim = 0; //Initialized
From C Standards#6.7.9p10 [Initialization]
If an object that has automatic storage duration is not initialized explicitly, its value is indeterminate.
From C Standards#J.2 [Undefined behavior]
The value of an object with automatic storage duration is used while it is indeterminate (6.2.4, 6.7.9, 6.8).
An undefined behavior includes it may execute incorrectly (either crashing or silently generating incorrect results), or it may fortuitously do exactly what the programmer intended.
Though you are getting the value of patty
and tim
variable same in the output but certainly they are not same.
$ ./integers
Patty: 0 <----- indeterminate value
Tim: 0 <----- value that tim initialized with