これはとても愚かです。私は文字通り1時間空白文字で区切られた数字の.txtファイルを読み込もうとしています。 whileループは何らかの理由で一度だけ実行されます!C++ .txtファイルからスタックへの整数の読み込み
#include <iostream>
#include <string>
#include <fstream>
#include <stack>
using namespace std;
int main(int argc, char* argv[])
{
string line;
string str(argv[1]);
ifstream myfile((str).c_str());
int num;
stack<int> x;
while (myfile >> num);
{
x.push(num);
}
return(0);
}
おそらくあなたは、なぜコンパイルの警告をすべて有効にすると主張しているのか分かります。 –
@CyberShot:問題ありません;-)残りのコードをニックピッキングした段落を追加しました。 。 – Cameron
@KerrekSB私は-Wallフラグを使用して警告を受け取りませんでした。 – CyberShot