正如标题所说,我的文本文件中几乎没有大写字母,所以如果没有首字母大写,所有句子看起来都不正确。到目前为止,这是我的代码:
//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 关键字。我还不知道在哪里设置它。