By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,171 Members | 1,004 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,171 IT Pros & Developers. It's quick & easy.

C++ read / modify text file help

P: 1
I am trying to write a program that will analyse a text file and do the following:

1. Count the number of characters.
2. Count the number of spaces.
3. Count the number of words.
4. Count the number of sentences.
5. Count the number of lines.
6. Ensure the 1st non-blank character in a sentence is capitalized. (I think this is done using a C function?)

Does anyone have any suggestion as to how I'd go about doing this? any samples of code / pointers to tutorials would be appreciated

I've got limited experience making easy games using visual C++, uisng timers etc but non visual C++ is still very alien to me!

Many Thanks!
Jun 16 '06 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 1,754
Hi there,

you seems to be asking some serious thing here buddy.. was just kidding.. i assume ur trying to create some sort of editor kind of application.. correct me if am wrong.. well.. there few site offering complete application together with their source code.. heard about GNU?? try looking in;
Jun 16 '06 #2

Expert Mod 5K+
P: 8,916
If sashi suggestions do not solve your problem then programatically what you need to do is
  1. Open the file
  2. Read it character by character (or read it in 1 lump into memory and scan that memory character by character which is more efficient).
  3. Work out a rule for all the various counts you require, for instance number of characters, number of spaces and number of lines are fairly obvious, sentences and capitalisation is only slightly harder, words are probably the trickest thing. No the easy ones first.
  4. Implement your rules.
Jun 16 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.