/****************************************************************************
@File Name: test.cpp
@Author: wangzhicheng
@mail: 2363702560@qq.com
@Created Time: Sat 04 Feb 2017 12:58:48 AM CST
****************************************************************************/
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
static const int LEN = 512;
char origin[LEN] = "58.56.110.98 -- 1264348800 \"GET http://www.baidu.com/web/validate/captcha.php?cid=134&3307 HTTP/1.0\" 404 534 \"-\" \"Micro Soft WTP Add-On 1.2.1046\" TCP_MISS:FIRST_UP_PARENT 13";
char p0[LEN] = "";
char p1[LEN] = "";
char p2[LEN] = "";
char p3[LEN] = "";
char p4[LEN] = "";
char p5[LEN] = "";
char p6[LEN] = "";
char p7[LEN] = "";
char p8[LEN] = "";
char p9[LEN] = "";
char p10[LEN] = "";
int main(int argc, char **argv)
{
sscanf(origin, "%s --%s %*[\"]%s %s %[^\"]\" %s%s %*[\"|-] \"%[^\"]\"%s%s", p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
// p0 -- 58.56.110.98
// p1 -- 1264348800
// p2 -- GET
// p3 -- http://...
// p4 -- HTTP/1.0
// p5 -- 404
// p6 -- 534
// p7 -- Trend Micro WTP Add-On 1.2.1046
// p8 -- TCP_MISS:FIRST_UP_PARENT
// p9 -- 13
cout << p0 << endl;
cout << p1 << endl;
cout << p2 << endl;
cout << p3 << endl;
cout << p4 << endl;
cout << p5 << endl;
cout << p6 << endl;
cout << p7 << endl;
cout << p8 << endl;
cout << p9 << endl;
return 0;
}
sscanf
最新推荐文章于 2024-07-06 05:00:00 发布