Ok, you have modified the original code, but you could have also notified us of it and told us what is not right now.
Code:
char fileName[80];
char buffer;
These are both unused and should be removed.
Code:
ifstream TheFile("f2.txt");
ofstream TheCopy;
TheCopy.open ("YourCopy.txt",ios::app);
char ch, pre = '\0';
...
if (pre == ' ' || pre == '\n')
Does it give you an idea why the first word is not capitalized - unless the file begins with a space?
Code:
while (TheFile.get(ch))
{
if (pre == ' ' || pre == '\n')
cout.put(char(toupper(ch)));
else cout.put(ch);
TheCopy << ch;
pre = ch;
}
Do you have any idea why you see correct output on the screen (apart from the first word) but not in the output file?
Hint, toupper does not modify the argument. It returns the upper-case character.