Featured
- Get link
- X
- Other Apps
Program to display 3 character words in C++ Text File
//Program to count 3 character words in C++ Text File
#include<fstream.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
void ADDDATA()
{
fstream f;
f.open("STORY.TXT",ios::out);
f<<"The Tajmahal is famous for its grandeur. The Taj is also famous for its marble.";
f.close();
}
void DISP3CHAR()
{
fstream f;
f.open("STORY.TXT",ios::in);
char word[30];
f>>word;
while(f)
{
if(strlen(word)==3)
cout<<word<<"\t";
f>>word;
}
f.close();
}
void main()
{
int ch; char ans;
do
{
clrscr();
cout<<"1.ADD DATA in FILE\n";
cout<<"2 Display 3 Letter Words in FILE\n";
cout<<"3.EXIT\n";
cout<<"\nEnter Your Choice\n";
cin>>ch;
if(ch==1)
{
ADDDATA();
}
if(ch==2)
{
DISP3CHAR();
}
if(ch==3)
{
exit(0);
}
cout<<"Wanna See Menu Again Y/N"<<endl;
cin>>ans;
}while(ans=='y'||ans=='Y');
}
OUTPUT:
#include<fstream.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
void ADDDATA()
{
fstream f;
f.open("STORY.TXT",ios::out);
f<<"The Tajmahal is famous for its grandeur. The Taj is also famous for its marble.";
f.close();
}
void DISP3CHAR()
{
fstream f;
f.open("STORY.TXT",ios::in);
char word[30];
f>>word;
while(f)
{
if(strlen(word)==3)
cout<<word<<"\t";
f>>word;
}
f.close();
}
void main()
{
int ch; char ans;
do
{
clrscr();
cout<<"1.ADD DATA in FILE\n";
cout<<"2 Display 3 Letter Words in FILE\n";
cout<<"3.EXIT\n";
cout<<"\nEnter Your Choice\n";
cin>>ch;
if(ch==1)
{
ADDDATA();
}
if(ch==2)
{
DISP3CHAR();
}
if(ch==3)
{
exit(0);
}
cout<<"Wanna See Menu Again Y/N"<<endl;
cin>>ans;
}while(ans=='y'||ans=='Y');
}
OUTPUT:
- Get link
- X
- Other Apps
Labels:
3 letter word count program in C++
file handling program to count 3 letter words and display
Word Count Program in C++
Popular Posts
C++ program to display numbers which get reversed after multiplying by 4
- Get link
- X
- Other Apps
Comments
Post a Comment