首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

格式化字符串有关问题

2013-01-08 
格式化字符串问题char cmdbuf[] set 1 hello world!我现在需要取出“hello world”(含有空格),hello前有

格式化字符串问题
char cmdbuf[]= "set 1 hello world!";
我现在需要取出“hello world”(含有空格),hello前有多少个字符是未知的,
通过sscanf(cmdbuf, "set 1 %s", buf1)操作后取到的buf1是hello,因为遇到空格就结束了。
请问各位大侠有没有什么简单的方法能取出"hello world"?
[解决办法]
楼主哪去了啊,我都来两次了。。。


[解决办法]
char cmdbuf[]= "set 1 hello world!";
string subStr = "hello";
string str = cmdbuf;
char * pFind = strstr(cmdbuf, subStr.c_str());
cout<<pFind<<endl;

热点排行