首页
学习
活动
专区
圈层
工具
发布

L005Linux和androidNDK之c语言中的正则表达式

这一块很好玩,熟悉的话,编程起来也很有效率~ 待补充~~

测试代码

获取字符串中的指定信息

代码语言:javascript
复制
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <ctype.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <linux/if.h>
#include <linux/sockios.h>
#include <sys/statfs.h>
#include <arpa/inet.h>

//获取http应答帧的返回值
int test()
{
    char *s1="HTTP/1.1 200 OK\r\n";
    char *ss="HTTP/1.1 505 hdhdh\r\n";
    char *str=ss;
    int a=0;

    sscanf(str,"%*[^ ]%d%*[^1]",&a);

    printf("a=%d\n",a);
}

int main(int argc,char **argv)
{
    test();
}
下一篇
举报
领券