I am learning C and getting into structures, but I am getting a lot of errors I don't know how to fix.
I am using xCode, and I've made a header file. This is what I have in my header file:
Code:struct player { int playerID; char rank[25]; char fieldType[25]; int level; };
The first error I get is "Type 'struct player' has incompatible definitions in different translation units".
I've already included the header file and <sys/player.h> in the main editor. So far, this is what I have in my main editor:
Code:#include <stdio.h> #include <stdlib.h> #include "Header.h" (this is the name of my header file) #include <sys/player.h> int main () { struct player newbie; newbie.playerID = 10; printf("Enter the RANK of player 10: "); gets(newbie.rank); printf("\nEnter the FIELD TYPE of player 10"); gets(newbie.fieldType); printf("\nEnter the LEVEL of player 10"); gets(newbie.level); return 0; }
Then I got these errors:
No member named 'playerID' in 'struct player'
No member named 'rank' in 'struct player'
No member named 'fieldType' in 'struct player'
No member named 'level' in 'struct player'
What am I missing?