Hi all, I'm trying to write a program that reads text from external file (string string int, per line). Struct is defined outside of main function:
typedef struct Person {
char fname[15];
char lname[20];
unsigned long int birth;
} clovek;
I don't need "clovek" to be an array as with every line data can be overwritten. Line is red to buffer with:
fgets(buffer, 50, datafile);
Then I want to parse it to the struct but that is where my problem arises:
int i = 0;
while (buffer[i] != ' ') {
clovek.fname[i] = buffer[i];
i++;
}
And this gives me out an error: expected identifier or '(' before '.' token
I also wanted to use this code for debugging but it gives out another error as well:
printf("fname, %s\n", clovek.fname);
error: expected expression before 'clovek'
My guess is that I totaly misunderstood using of struct.