So I have a textfile which goes like this:
zero three two one five zero zero five seven .. etc
and there is a lot of it, 9054 words to be exact
My idea was to create a char array of 9054 spaces and store it in, this is what I have done so far:
#include <stdio.h>
int main(void)
{
char tmp;
int i = 0;
int j = 0;
char array[44000];
FILE *in_file;
in_file = fopen("in.txt", "r");
// Read file in to array
while (!feof(in_file))
{
fscanf(in_file,"%c",&tmp);
array[i] = tmp;
i++;
}
// Display array
while (j<i)
{
printf("%c",array[j]);
j++;
}
fclose(in_file);
while(1);
return 0;
}
The problem is I don't know how to store words, because from what I have done stores each character into the array so it becomes an array of around 44000. How can I make it so the array holds words instead?
Also I don't have an idea what the feof function does, especially the line
while (!feof(in_file))
what does this line exactly mean? Sorry I am still in the baby stages of learning C, I tried looking up what feof does but there is not much to find