私は次のテキストファイルの単語を読み、 "@ name @"と "@ festival @"という単語を置き換えています。私のプログラムは@ name @のためには完全に動作しますが、最初の@festival @だけを変更しますが、2番目の@は変更しません。なぜ私は考えていない。テキストファイル内の1つの単語を置き換えることはできますが、別の単語を置き換えることはできますか?
ジョン・ドウ
ルーム213-
ジェネリック旧ビル
情報技術科
プログラミング州立大学
ニューヨークNY 12345から0987
USA
へ:季節の挨拶:名@
件名@名@ @
親愛なる、
A非常に祭り@ @ @ @祭りあなたとあなたの家族に!
あなたの誠実、
ジョン
void Main::readFile()
{
while (v.size() != 0) {
string name;
name = v.at(v.size()-1);
v.pop_back();
std::ofstream out(name + ".txt");
ifstream file;
file.open("letter.txt");
string word;
string comma;
char x;
word.clear();
while (!file.eof())
{
x = file.get();
while (x != ' ' && x != std::ifstream::traits_type::eof())
{
if (word == "@[email protected]") {
word = name;
}
if (word == "@[email protected]") {
word = "THISISATEST!!!!!!!!!!!!!!";
}
word = word + x;
x = file.get();
}
out << word + " ";
word.clear();
}
}
コードをステップ実行したときにデバッガはあなたに何を表示しますか? –