【问题标题】:sscanf to stringstream conversionsscanf 到 stringstream 的转换
【发布时间】:2023-03-25 15:41:02
【问题描述】:
 if (1 != sscanf(line, "%s", name)) continue;

在我们之前的代码中

char line[128];

char name[128];

使用 istringstream 而不是 sscanf 来编写这一行的另一种方法是什么?

【问题讨论】:

  • 同意。不会对此发表答案..
  • 让他休息一下。他才来这里28天。我经常在至少一个月后才接受答案。

标签: c++ istringstream


【解决方案1】:
std::istringstream stream( line );
if( !( stream >> name ) )
    continue;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-19
    • 1970-01-01
    相关资源
    最近更新 更多