タイトルが示すように、ほとんど大文字が含まれていないテキスト ファイルがあるため、最初の文字を大文字にしないと、すべての文が正しく表示されません。これまでの私のコードは次のとおりです。
//This program reads an article in a text file, and changes all of the
//first-letter-of-sentence-characters to uppercase after a period and space.
#include <iostream>
#include <fstream>
#include <string>
#include <cctype>//for toupper
using namespace std;
int main()
{
//Variable needed to read file:
string str;
string input = str.find('.');
//Open the file:
fstream dataFile("eBook.txt", ios::in);
if (!dataFile)
{
cout << "Error opening file.\n";
return 0;
}
//Read lines terminated by '. ' sign, and then output:
getline(dataFile, input, '. ');//error: no instance of overloaded function "getline"
//matches the argument list
//argument types are:(std::fstream, std::string, int)
while (!dataFile.fail())
{
cout << input << endl;
getline(dataFile, input);
}
//Close the file:
dataFile.close();
return 0;
}
. 注: 私のコードにはまだ toupper キーワードがないことを知っています。どこに設定するかはまだわかりません。