I have the following c++ code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void main()
{
ifstream file;
file.open("file.txt", fstream::out);
string text;
while (!file.eof()) {
getline(file, text);
}
file.close();
for (int i = 0; i < 30; i++) {
if (text[i] == ' ' && text[i + 1] == 'a' || "o") {
text[i + 1] = toupper(text[i + 1]);
}
}
Text of the file:
Cats odds abses intro obsession jam
And I need co capitalize the first letter of words that begin with "a" or "o",but it capitalizes each letter.
Does somebody know how to fix this?
Will be thankful for any answer.