貌似调用两次strstr就好了
#include
#include
#include
int main()
{
char *buf="# 2013-09-29 09:35 +00566 +39.0 13.4 +00.0 +00.0 0 01935 04 D9 D9 0595 002 AIRP 20130929093800 0 00010071 EB EB EB # 05920011 2013-10-08 13:28 00.00 147 00.00 147 12.0";
char* p04D9D9 = strstr(buf, "04 D9 D9");
char* pEBEBEB = strstr(buf, "EB EB EB");
int partLen = pEBEBEB - p04D9D9 + 8; // len of "EB EB EB" is 8
char* p = (char*) malloc((partLen + 1) * sizeof(char));
strncpy(p, p04D9D9, partLen);
p[partLen] = 0;
puts(p);
free(p);
}
搜索呀,从头到尾遍历这个数组,搜索开头和结尾标志,然后去中间字符,计算长度。
char head[1024] = {0};
char body[1024] = {0};
sscanf(buf, "%s04 D9 D9%sEB EB EB", head, body); // body就是你要的内容