So the first part of this code is reading any random text file and printing the total number of words in it, which I understand, but for the second part (the ?????? part) the number of different words must be printed. Not the number of unique words, which are words that only occur once, but different words, which are the unique words plus one of each repeating word.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 80
typedef char string[MAX+1];
void main()
{
char file[MAX], s[MAX];
int count = 0, i, j;
FILE *inFile;
printf("Input file name: ");
scanf("%s", &file);
inFile = fopen(file,"r");
if (inFile == NULL)
{
printf("\n\nFile does not exist or cannot be opened.\n");
exit(1);
}
while (fgets(s, MAX, inFile) !=NULL)
{
for (i = 0; s[i] != '\0';i++)
{
if (s[i] == ' ')
count++;
}
}
int total= count + 1;
printf("The total number of words in the file is: %d\n", total);
?
?
?
?
?
?
?
fclose(inFile);
int different = ?
printf("The total number of different words in the file is: %d\n", different);
*
*
*
How do I go about counting and printing this?