【问题标题】:How to skip to next line after the last number found in each line when reading a text file?读取文本文件时如何在每行中找到最后一个数字后跳到下一行?
【发布时间】:2015-07-10 10:50:02
【问题描述】:

我的文本文件如下所示:

1    2   3      test//test
4    5   6    dummy//dummy

我怎样才能读取这个文件并且只处理每一行中的数字?

【问题讨论】:

  • 阅读忽略功能
  • Xupicor 对您的非常类似问题的回答here 可以轻松适应此要求...您尝试过什么吗?
  • @TonyD 其实我已经根据你的回答完成了任务,这是一个相当多余的问题,哈哈 :)

标签: c++ parsing input output readfile


【解决方案1】:

两种方式:

  1. ignoring the rest of the line

  2. reading the complete line转入a string,将字符串放入an output string stream,并从输出字符串流中只读取前三位数字。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-09
    • 2022-01-15
    • 2012-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多