How to read data from files in Turbo c++ 4.0?

后端 未结 2 1966
时光说笑
时光说笑 2021-01-29 12:59

I am a beginner in programming and I am trying to make a code that reads 2 numbers from a file and then displays it in the output window on turbo c++. My code only reads the fi

相关标签:
2条回答
  • 2021-01-29 13:26

    Try using infile>>x>>y inside the while loop condition like this

    while(infile>>x>>y)
    

    then use the cout statement in the loop.

    0 讨论(0)
  • 2021-01-29 13:40

    The std::cout should be inside the while loop:

    while(!inFile.eof()){
         inFile >> x >> y;
         cout << x << " " << y;
    }
    
    0 讨论(0)
提交回复
热议问题