|
楼主 |
发表于 2009-11-6 09:26:40
|
显示全部楼层
这个是通过了的,可是写成函数就不太懂了,上面的函数运行后,
提示:Segmentation fault.(那里超界访问了?)
unsigned int in=0;
unsigned int vals[20];
unsigned char wvals[20];
char source[30];
char *p[20];
char inputbuf[255]="A0,A1,A2";
char *buf=inputbuf;
while((p[in]=strtok(buf,",")) !=NULL)
{
sscanf(p[in],"%X",&vals[in]);
buf=NULL;
in++;
//printf("%s",p[in]);
//if (in>29) break;
}
int i=0;
for (i=0;i<in;i++)
{
wvals=vals;
}
wvals[in+1]=0;
if (wvals[0] == 0xA0) printf("0 OK\n");
if (wvals[1] == 0xA1) printf("1 OK\n");
if (wvals[2] == 0xA2) printf("2 OK\n");
if (wvals[3] == 0xbf) printf("3 OK\n"); |
|