#include "stdio.h" correct? code example

Example: #include

/*
Desperation: This program will have that reports how many lines, words, and characters in an input text file with more than 300 words,
and at least 3 paragraphs, and also makes a sorted list of all words found in it. You are required to provide the text file.
Write the sorted list to an output file, along with the number of times each word appeared in the input file.
For the purpose of this program, a word consists of a consecutive sequence of any characters except white space characters
Programmer: Atifa Masoudi
Programmer ID: 156308199
Date:07/09/2020
*/




#include 
#include 
#include 
#include 

#define MAX 1000
int main(void)
{
	int wordcount = 0, charcount = 0;
	FILE *fptr, *fptr1;
	int i, len, index, isUnique;
	
	char words[MAX][50];
	char temp[50];
	int t;
	char word[50];
	
	int count[MAX];

	fptr = fopen("file.txt", "r");

	if (fptr == NULL)
	{
		printf("Unable to open file. ");
		exit(1);
	}

	for (i = 0; i= 'A'&&word[i] <= 'Z')
			{
				word[i] = word[i] + 32;
			}
		}
	
		isUnique = 1;
		for (i = 0; i 0)
			{
				strcpy(temp, words[i]);
				strcpy(words[i], words[j]);
				strcpy(words[j], temp);
			
				t = count[i];
				count[i] = count[j];
				count[j] = t;
			}
		}
	}
	wordcount = index;
	for (int i = 0; i %d ", words[i], count[i]);
	}
	return 0;
}

Tags:

Misc Example