Getting input from external files?

后端 未结 4 2043
我在风中等你
我在风中等你 2021-01-28 11:36

I need to get very basic input from an external file in C++. I tried searching the internet a few times but nothing really applied to what I need. This would be a .txt file that

4条回答
  •  灰色年华
    2021-01-28 12:08

    Create an std::ifstream object, and read from it just like you would from std::cin. At least if I understand what you're trying to do, the 131 as the first input is really intended to be three separate numbers (1, 3, and 1). If so, it's probably easiest to change your input file a bit to put a space between each:

    1 3 1
    2 4 1
    3 7 1
    4 8 1
    

提交回复
热议问题