I'm still a bit of a newbie and have what is probably a minor issue, but for some reason I can't wrap my mind around it.
I have a program that does a whole bunch of stuff to text from an input file. The input looks like this:
MArch 9, 1971. SPace the finAL fronitIER!
"TheSe aRe the voyAges of the staRship
enTERprIse"?
With the current result looking like:
March 9, 1971. Space the final fronitier!
"These are the voyages of the starship
enterprise"?
But what I need to do is get rid of all of the spaces and format it so....
March 9, 1971. Space the final fronitier!
"These are the voyages of the starship
enterprise"?
If I read in the string one word at a time, I can easily concatenate the ouput , ( cout <<text+' ')
but the way that I read in the input, I used get(ch), which isn't playing nice for me so far.
So how do I concatenate the output?
Any help would be greatly appreciated and here is the code for this segment of my program...
input.get(ch);
if (ch=='"')
{
new_sentence=true;
cout << (char)ch;
}
else
{
new_sentence=false;
cout << (char)toupper(ch);
}
while(input.get(ch))
{
if(isalpha(ch))
{
if( new_sentence )
cout << (char)toupper(ch);
else
cout << (char)tolower(ch);
new_sentence = false;
}
else
{
if( ch == '.' || ch == '!' || ch == '?')
new_sentence = true;
cout << (char)ch;
}
Thanks in advance!
Robert