70,022
社区成员




#include <stdio.h>
#include <stdlib.h>
int main ()
{
int a, b, d;
char c[16];
char buf[] = "5, 10, str, 0xFFBC";
sscanf(buf, "%d, %d, %[^,], 0x%X", &a, &b, c, &d);
printf("the date is %d, %d, %s, 0x%X.\n", a, b, c, d);
sscanf(buf, "%*d, %*d, %*[^,], %s", c);
printf("c=%s\n", c);
return 0;
}
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void )
{
int a,b;
char c[16];
char d[16];
char * p;
char buf[128] = "5, 10, str,0xFFBC";
p=strstr(buf,"str,");
if(p)
{
p=p+4;
strcpy(d, p);
printf("BUF:%s\n",d);
}
return 0;
}
附个代码吧。