I tried this code after documenting myself :
struct person
{
int a;
char s;
};
struct person test;
test.a = 12;
And Code::Blocks returns this following error :
error: 'test' does not name a type
Can someone explain this error to me? I found this sample code on the internet! I don't understand my mistake.
Thanks for reading, have a nice day.
To make your code work you need to put it in a function and there should be a main function too.
struct person
{
int a;
char s;
};
int main() // you need to have a main
{
// code needs to be in a function
/*struct*/ person test; // struct is not needed
test.a = 12;
return 0;
}