Hello everyone. The problem I am having is that I am reading from a predefined text file with this type of stucture:
Code:
name id
name id
name id
name id
name id
What I am trying to do is to read all of the names into one array and all of the ids into another.
Code:
char* name[4];
int ids[4];
I need to use the method fgets(). I can successfully read the file, but am not sure of the correct way of putting them into the array. I was trying something like this, but to no avail:
Code:
	i = 0;

	while (fgets(line, 2048, pfile) != NULL) 
	{
		printf("%s", line);
		strcpy(stid[i], line);
		i++;
	}
From my results, it outputs everything perfectly to the console, but I can't figure out a way to put the data in arrays. Right here, I am just attempting to put the whole line into an array. If you can put me on the right track, I can split the data up later on my own. I just need help on the right way to write to arrays.