I have a txt
file that looks like the following:
1:0
2:0
3:1
4:0
...
99:1
100:1
I would like to store the 1
s and 0
s inside an array (slot[]
), (regardless of what's on the left side of the ':
's), but I can't figure out how. Here's a snippet of my code for that:
while((ch=fgetc(fptr)) != EOF)
{
if(ch == ':')
{
slot[j] = fgetc(fptr); //saves the character right after ":"into slot[j]?
j++;
}
}
I know it's more complicated than this because it doesn't work. I've searched for a long time but can't find it, maybe because I didn't search for the correct terms.
How can I fix this?
Thanks in advance.