Write a function in C++ to count and display the number of lines not starting with alphabet 'A' present in a text file "STORY.TXT".
Write a function in C++ to count and display the number of lines not starting with
alphabet 'A' present in a text file "STORY.TXT".
Example:
If the file "STORY.TXT" contains the following lines,
The roses are red.
A girl is playing there.
There is a playground.
An aeroplane is in the sky.
Numbers are not allowed in the password.
The function should display the output as 3.
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ifstream fin;
fin.open("Story.txt");
char str[100];
int count=0;
int count1=0;
while(!fin.eof())
{
fin.getline(str,100);
if(str[0]!='A')
{
count++;
}
else if(str[0]=='A'&&str[1]==' ')
{
count1++;
}
}
cout<<"The number of lines not starting with 'A' are:"<<count<<"\n";
cout<<"The number of lines starting with 'A' are:"<<count1<<"\n";
fin.close();
return 0;
}
alphabet 'A' present in a text file "STORY.TXT".
Example:
If the file "STORY.TXT" contains the following lines,
The roses are red.
A girl is playing there.
There is a playground.
An aeroplane is in the sky.
Numbers are not allowed in the password.
The function should display the output as 3.
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ifstream fin;
fin.open("Story.txt");
char str[100];
int count=0;
int count1=0;
while(!fin.eof())
{
fin.getline(str,100);
if(str[0]!='A')
{
count++;
}
else if(str[0]=='A'&&str[1]==' ')
{
count1++;
}
}
cout<<"The number of lines not starting with 'A' are:"<<count<<"\n";
cout<<"The number of lines starting with 'A' are:"<<count1<<"\n";
fin.close();
return 0;
}
hello bro
ReplyDeletebro your code is not working
ReplyDeleteCasino Games - JTM Hub
ReplyDeleteIn the latest 전라북도 출장마사지 news about casino games, check out the latest 충주 출장샵 information 밀양 출장샵 about 군산 출장마사지 your Casino Games, 문경 출장마사지 your top-rated options and top-rated bonuses. Get more!