1
我到目前爲止這段代碼反向文本文件中的行:C++:使用堆棧
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
#include <string>
#include <stack>
using namespace std;
int main() {
ifstream in;
in.open("example.txt");
ofstream outfile;
outfile.open("out.txt");
stack<string> lines;
string temp;
while(getline(in, temp))
lines.push(temp);
while(!lines.empty())
outfile << lines.pop() << endl;
in.close();
outfile.close();
return 0;
}
我的問題是,爲什麼我得到的編譯錯誤「敵不過在OUTFILE操作< <」 。
附加題 - 如何做,如果你的文件有100M行此代碼的工作? – 2012-04-19 17:28:01
醫管局,而不是家庭作業。我有一個.bmp,我轉換爲二進制文件,但它倒過來。我只是需要翻轉它之前,我開始將二進制轉換爲十六進制,然後將其放入數組的屏幕圖像進行。小屏幕效率並不重要。 – LiverpoolFTW 2012-04-19 17:29:48