Apostrophe

I am trying to use the code below to check a file and capitalize the first letter of every sentence. The code works until it reaches an apostrophe. I think I am over complicating this but for the life of me can’t think of another way to do this. Is there another way to check for a valid char instead of using “if(isalpha(ch)) || ispunct(ch))”. Any help will be much appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void checkCaps(ifstream& infile, ofstream& outfile)
{
   bool start_sent = true;
   char ch;
   while(infile.get(ch))
	{
	if(isalpha(ch) || ispunct(ch))
	{
           if(start_sent) 
	  outfile.put(toupper(ch));
	  else outfile.put(ch);
	  start_sent = false;
	}
	else
	{
	   if(ch == '.') start_sent = true;
	   outfile.put(ch);
	}
	}
}
Last edited on
What happens when you reach an apostrophe?

Andy

P.S. What system/IDE/... are you using?
P.P.S. Is a full stop/period punctuation?
Topic archived. No new replies allowed.