64,642
社区成员
发帖
与我相关
我的任务
分享
#include <fstream>
#include <vector>
#ifdef _DEBUG
#include <iostream>
#endif
using namespace std;
int main()
{
vector<int> ivec;
ifstream ifs("Input.txt");
int i;
while (ifs >> i) {
#ifdef _DEBUG
cout << i << " ";
#endif
ivec.push_back(i); // 保存到向量中ivec中
}
ifs.close();
return 0;
}
Input.txt:
12
23 34 56
ifstream if("yourtext.txt", ios::in);
int i;
while(if>>i)
{
cout<<i<<endl;
}