【C&C++】sscanf的用法测试

我也不写说明了, 转一个博客地址,然后给出我今天测试的所有方面的代码
我想理解的话,在C语言里如何去解析字符串就不再是一个问题了。
http://www.cnblogs.com/redstar/archive/2007/10/11/921554.html

#include < iostream >
#include
< fstream >
#include
< cstdlib >
#include
< cstring >


using namespace std;


int main()
... {

/**//*sscanfparsetests*/
intd=0;
charbuf[20];
//sscanf("parent2","%*s%d",&d);/*CanParseCorrectly*/
//sscanf("parent25","parent%d",&d);/*result25returned*/
//sscanf("parent2","%*s%d",&d);/*Cannotparsebecause%sisassigned"parent2"*/
//sscanf("parent2","%*6s%d",&d);/*CanParseCorrentlyBecausewidthspecified*/
//sscanf("parent2","%*[a-z]%d",&d);/*ParseCorrectlyuseWildCard*/
//sscanf("parent2parent","%*[a-z]%d",&d);/*ParseCorrectlyuseWildCard*/
//sscanf("parent22parent","%*[a-z]%1d",&d);/*result2returned*/
//sscanf("asd/35@32","%*[^/]/%d",&d);/*result35returned*/
sscanf("iios/12DDWDFF@122","%*[^/]/%[^@]",buf);
cout
<<d<<endl;


inta,b,c;
sscanf(
"2006:03:18","%d:%d:%d",&a,&b,&c);
cout
<<a<<b<<c<<endl;

return0;
}

你可能感兴趣的:(html,C++,c,C#,D语言)