Hi,
With the piece of code:
1 #include <stdio.h>
2
3 typedef struct {
4 int x;
5 int y;
6 } addr;
7
8 typedef struct addr a;
9
10 int main() {
11 addr array[5];
12. printf("%d\n", sizeof(array)/sizeof(addr));
13. return 0;
14. }
Having this error:
nettest.cpp:8: error: using typedef-name ‘addr’ after ‘struct’
nettest.cpp:6: error: ‘addr’ has a previous declaration here
nettest.cpp:8: error: invalid type in declaration before ‘;’ token
nettest.cpp: In function ‘int main()’:
nettest.cpp:12: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’
How to do it correctly?