我能夠寫入文本文件,然後使用getline,我不能再寫入文件。C++當我使用getline從文件讀取後,我不能再寫入到txt文件
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
ifstream infile;
fstream crypto;
ofstream hacker;
string tempString;
string tempString2;
string plaintext;
string line;
string dec;
.
.
.
crypto<<"hello";//write some stuff to file here
use getline(crypto, line, '\n')
crypto<<"hi";//Doesnt write to file anymore.
我認爲問題與嘗試從文件同時讀取和寫入有關。如果這不是錯誤,則錯誤將出現在getline中,以及您如何使用。 – Jim 2010-11-02 03:05:23