替代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:你需要包括