sscanf到stringstream的转换

时间:2011-10-29 00:19:16

标签: c++ istringstream

 if (1 != sscanf(line, "%s", name)) continue;

我们在代码的前面有

char line[128];

char name[128];

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

1 个答案:

答案 0 :(得分:0)

std::istringstream stream( line );
if( !( stream >> name ) )
    continue;