I have been checking Google for an hour. I have tried using typdef but I get the same results. I am having a bit of confusion in regard to structure scopes. I’m sure it’s just something silly that I’m missing.
Example, prints 0:
#include <stdio.h>
struct info
{
int i;
};
struct info testinfo;
int test()
{
testinfo.i = 5;
}
int main()
{
printf("%d", testinfo.i);
}
Both struct info have block scope since you declare them as local variables.
They are thus different objects.
Declare only one at file scope (outside any function).
(Code in question has been edited and this answer refers to the initial bug).