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でオペレータ< <のために一致なし」のコンパイルエラーを取得しなかった理由。
エクストラクレジット:
top()
、その後pop()
を使用しますか? –HA、宿題なし。私はバイナリに変換した.bmpを持っていますが、それは逆さまです。私は、バイナリを16進数に変換してから、画像が表示される画面の配列に配置する前に、それを反転する必要がありました。小さな画面なので効率は重要ではありません。 – LiverpoolFTW