【发布时间】:2011-05-03 17:50:11
【问题描述】:
我可以写入文本文件,然后我使用 getline,但我无法再写入该文件。
#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 以及您的使用方式。