Reading in a specific column of data from a text file in C

前端 未结 4 982
说谎
说谎 2020-12-04 02:56

My text file looks like this:

987 10.50   N   50
383 9.500   N   20
224 12.00   N   40

I want to read only the second column of data. How w

4条回答
  •  离开以前
    2020-12-04 03:32

    You can't just read the second column without reading anything else.

    What you can do is read all the data, and ignore everything but the second column. For example, read a line of data (with std::getline) then from it extract an int and a double, but ignore both the int and the rest of the line.

提交回复
热议问题