g++ コンパイラを使用して Linux で実行する簡単なプログラムがあります。
#include <string>
#include <sstream>
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char **argv){
fstream file;
string s;
file.open("sample/dates.dat", fstream::in);
if(!file.good())
return 0;
getline(file, s);
cout << s << "." << endl;
return 0;
}
コンパイル済み: g++ -o test test.cpp
. これを実行すると、文字列 s の後ではなく前にフルストップが出力されます。なぜこれが起こっているのか誰にも分かりますか?そして、それは簡単に修正できますか?
ありがとう。