从在C文本文件中的数据的一个特定的列读 [英] Reading in a specific column of data from a text file in C

查看:144
本文介绍了从在C文本文件中的数据的一个特定的列读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的文本文件看起来像这样:

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 would I got about doing this?

推荐答案

您不能只是读第二列不读任何东西。

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

你可以做的是读取所有数据,而忽略一切,但第二列。例如,读取数据的线路(的std ::函数getline ),然后从中提取一个 INT 双击,却忽略了两者 INT 和行的其余部分。

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.

这篇关于从在C文本文件中的数据的一个特定的列读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆