尝试创建I / O txt文件

时间:2018-10-14 16:28:21

标签: c++

因此,我正在遵循教授的简报,我认为我在做什么是正确的,我遇到的问题是执行程序时我无法输入任何内容。 底部图片 “输入文件应具有一些由空格分隔的整数值(例如10个值)。”

#include<iostream>
#include<fstream>
using namespace std;

int main()
{
ifstream myfile;
ofstream newfile;
myfile.open("test.txt");
newfile.open("new_test.txt");
cout <<"test.txt is opened to get input from it"<<endl;
cout <<"new_test.txt is opened to write in it"<<endl;

int mynum;
while(!myfile.eof())//finding whether end of file is reached
{
    myfile>>mynum;
    newfile<<mynum<<endl;
}
myfile.close();
newfile.close();

return 0;
}

Image

我的程序不允许我输入任何字母/数字或其他任何东西。

0 个答案:

没有答案