How to write Program to count number of times the word 'the' as an independant word in a text file in C++ Programming.
![]() |
C++ Program to Counting Words "the" in a Text File |
//Program to count number of times the word 'the' as an independant word in a text file.
//out.txt:-"The C++ is a the general purpose the programmingthe language."
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<string.h>
void main()
{
clrscr();
char a[80];
int count=0;
ifstream ifile("out.txt");
while(!ifile.eof())
{
ifile>>a;
if((strcmp(a,"the")==0)||(strcmp(a,"The")==0));
count++;
}
cout<<endl<<"Number of 'the' in the file out.txt: "<<count;
getch();
}
This C++ Program to count number of times the word 'the' as an independant word in a text file.
Learn More :
Text file
- Read Content From a Text File then Count and Display the Number of Alphabets
- C++ Program to count number of blanks present in a text file
- C++ Program to count number of words in a text file
- C++ Program to Count Lines Starting Alphabet 'A' in text file
- C++ Program to Print lower-case vowels in second.txt from first.txt
Count Number
Data File Handling
- C++ Program To Count Number Of Alphabets In A File
- C++ File Handling Binary files - class EMPLOYEE
- C++ Program To Write Numbers 1 to 100 in a data file
- C++ Initializes A String Variable And Outputs String To Disk File
- Read Content From a Text File then Count and Display the Number of Alphabets
- C++ Program to count number of blanks present in a text file
- C++ Program to count number of words in a text file