Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/156.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
替代sScFun()的C++_C++_Cin_Scanf - Fatal编程技术网

替代sScFun()的C++

替代sScFun()的C++,c++,cin,scanf,C++,Cin,Scanf,我有以下功能: static void cmd_test(char *s) { int d = maxdepth; sscanf(s, "%*s%d", &d); root_search(d); } 如何在C++方式中实现相同的输出,而不是使用sSCANF?< /P> 读取不存储在任何位置的字符串,然后读取十进制整数。使用流,它将是: std::string dont_care; int d = maxdepth; std::istringstream

我有以下功能:

static void cmd_test(char *s)
 {
    int d = maxdepth;
    sscanf(s, "%*s%d", &d);
    root_search(d);
  }
如何在C++方式中实现相同的输出,而不是使用sSCANF?< /P> 读取不存储在任何位置的字符串,然后读取十进制整数。使用流,它将是:

std::string dont_care;
int d = maxdepth;

std::istringstream stream( s );
stream >> dont_care >> d;
读取不存储在任何位置的字符串,然后读取十进制整数。使用流,它将是:

std::string dont_care;
int d = maxdepth;

std::istringstream stream( s );
stream >> dont_care >> d;

我得到:std::istringstream“具有初始值设定项,但类型不完整ERROR@user975900:您需要包括我得到的:std::istringstream“具有初始值设定项,但类型不完整ERROR@user975900:你需要包括