要获取字符串“adc,expires=600,dfdf”,中expires的值
1 #include<string.h>
2 #include<stdio.h>3 void main()
4 {
5 char a[35]="adc,expires=600,dfdf";
6 char *q=NULL;
7 char time[35]={0};
8 q=strstr(a,"expires=");
9 if(q!=NULL)
10 {
11 printf("find expires!\n");
12 int len=strlen("expires=");
13 strncpy(time,q+len,3);
14 }
15 printf("time=%s\n",time);
16 }
运行结果:
find expires!
time=600,dfdf