そのため、ファイルからすべての単語を読み取り、句読点を削除しようとしています。句読点を削除するロジックは次のとおりです。
編集:プログラムは実際には完全に実行を停止します。それを明確にしたいだけです
ifstream file("text.txt");
string str;
string::iterator cur;
for(file>>str; !file.eof(); file>>str){
for(cur = str.begin(); cur != str.end(); cur++){
if (!(isalnum(*cur))){
cur = str.erase(cur);
}
}
cout << str << endl;
...
}
次のようなテキスト ファイルがあるとします。
This is a program. It has trouble with (non alphanumeric chars)
But it's my own and I love it...
このビットのロジックの直後に文字列を挿入すると、次のようになりますcout
。endl;
This
is
a
program
It
has
trouble
with
non
alphanumeric
そしてそれはすべての人々です。イテレータのロジックに何か問題がありますか? どうすればこれを修正できますか?
ありがとうございました。