I am working on a project for a basic programming class and am not entirely familiar with strings and all. The goal of the program is to take one simple text file with a few random, repeated words, and return a file with each separate word and the number of times it appears in the file. The input file looks something like
Class
Text
Class
fall
mark
mark
Text
and the output should read,
Class 2
Text 2
fall 1
mark 2
I am having trouble reading and setting up an array for the input data. Not sure exactly how to set it up. Any suggestions would be great.
int main(void)
{
int k=0, p=0, words=0, match=0, ch=0;
double xx;
char I[WORD][LETTER;
FILE *file;
file = fopen("C:\\Users\\Andrew\\Documents\\te2.txt", "r");
if(file != NULL){
// Count the amount of words in file set up array
int i=0, j=0;
for(i=0; i<WORD; i++){
for(j=0; j<LETTER; j++){
fscanf(file, "%s", &I[i][j]);
ch++;
}}