C++ Program to Count Lines Starting Alphabet 'A' in text file

How to write a Program to count number of lines not starting with the alphabet 'A' in a text file in C++Programming.


C Program to Find the Number of Lines not starting with the alphabet 'A' in a text file in C++Programming.C Programming Examples on File Handling. How do I count the number of words in a text file using C++.C++ counting the number of lines in a text file
Program to count number of lines not starting with the alphabet 'A' in a text file in C++Programming.

Solution:
//Program to count number of lines not starting with the alphabet 'A' in a text file.
/*out.txt:-
*/

#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.getline(a,80);
if(a[0]!='A')
count++;
}
cout<<endl<<"Number of lines not starting with 'A' in the file out.txt: "<<count;
getch();
}

This C++ Program to count number of lines not starting with the alphabet 'A' in a text file.


Learn More :