My text file is as following:
Random Words //this only appears once at the top
Occupation1
1 2 3 4 5
6 7 8 9 10
Occupation2
11 12 13 14 15
16 17 18 19 20
I am having some trouble with the input and was wondering if you could take a look at my code.
typedef struct foo
{
char occupation[256];
int numbers[limita][limitb];
}FOO;
void function(FOO input[]);
int main()
{
FOO input[limit];
function(input);
return 0;
}
void function(FOO input[])
{
FILE* file;
file = fopen("textfile.txt","r");
int a=0; int b =0;
char temp[81];
char randomwords[81];
while(fgets(temp,sizeof(temp)-1,file))
{
sscanf(temp, "%[^\n] %[^\n] %d", randomwords,&input[a].occupation[a], &input[a].numbers[a][b]);
a++;
}
}
So I tried printing out (with printf) the random words and the occupation but to no avail. I don't think i'm using numbers correctly at all as it has to be a 2D array and don't seem to be changing the columns.
I would really appreciate a step in the right direction/some help. Please explain simply. Thank you very much.
EDIT: technomage brought up an interesting point regarding what i'm doing vs what I want. I'm not sure how to change in reflection to what he suggested though.