C struct declaration and initialization -


i have been following tutorials web on creating struct , initializing in main(). tutorials have followed, have created own example, follows:

#include <stdio.h>  struct test {     int num; };  main() {     test structure; } 

however, not work:

test.c: in function 'main': test.c:8: error: 'test' undeclared (first use in function) test.c:8: error: (each undeclared identifier reported once test.c:8: error: each function appears in.) test.c:8: error: expected ';' before 'structure' 

but when change:

test structure; 

to:

struct test structure; 

the code compiles. why though? numerous examples have looked @ seems shouldn't need 'struct' before 'test structure'.

thanks help/comments/answers.

you reading c++ examples. in c type of structure struct test not test.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -