Question about C struct

1
2
3
4
5
6
  struct names {
      char mine[7];
      char his[7];
};

struct names names1; 


In the code above, why can't I do the variable declaring like this : names names1? (without the struct keyword)
Because you must be using C rather than C++; in C, the names of all structs, enums, and unions are in their own name space. It's common in C to introduce a type alias in the name space of ordinary identifiers with a typedef declaration: typedef struct names names;
Last edited on
So struct names is 1 type?
Topic archived. No new replies allowed.