Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,171 questions

40,733 answers

573 users

How to count alphabetic characters in text file with C++

Freaking Awesome WordPress Hosting
98 views
asked Jun 13, 2018 by avibootz
edited Jun 13, 2018 by avibootz

1 Answer

0 votes
#include <iostream>
#include <fstream>

using std::cout;
using std::endl;

int main()
{
	std::ifstream ifs("d:\\data.txt");

	int counter = 0;
	char ch;

	while (!ifs.eof()) {
		ifs >> ch;
		if (isalpha(ch) && !ifs.eof()) {
			counter++;
		}
	}

	ifs.close();

	cout << counter << endl;

	return 0;
}

/*
run:

16

*/

 





answered Jun 13, 2018 by avibootz

Related questions

1 answer 104 views
1 answer 127 views
1 answer 118 views
2 answers 99 views
...