金鑫水淼的嵌入式开发学习博客
gofiend
全部博文(150)
2011年(1)
2009年(14)
2008年(135)
llinux
Bsolar
帅得不敢
yeyincan
零和博弈
liying10
wangzhen
giszy
云龙湖1
分类: LINUX
2008-09-27 11:00:01
void parse( char* message ) { char *pch; int counter=0; int i; //char *message1="hello-world"; printf( "can parse\n" ); pch = strtok( message,",*,\n"); while( pch != NULL ){ printf( "counter:%d---%s\n", counter ,pch); pch= strtok( NULL ,",*\n");
strcpy( save_info[counter], pch );//这儿错误,如果此时pch为NULL,则出错 counter++; } // printf( "the last counter is %d\n",counter );正常: for( i=0; i<counter;i++){ printf("save_info[%d]:%s\n",i,save_info[i]); }
strcpy( save_info[counter], pch );//这儿错误,如果此时pch为NULL,则出错
counter++; } // printf( "the last counter is %d\n",counter );
for( i=0; i<counter;i++){ printf("save_info[%d]:%s\n",i,save_info[i]); }
void parse( char* message ) { char *pch; int counter=0; int i; //char *message1="hello-world"; printf( "can parse\n" ); pch = strtok( message,",*,\n"); while( pch != NULL ){ strcpy( save_info[counter], pch ); printf( "counter:%d---%s\n", counter ,pch); pch= strtok( NULL ,",*\n"); counter++; } // printf( "the last counter is %d\n",counter ); for( i=0; i<counter;i++){ printf("save_info[%d]:%s\n",i,save_info[i]); }
上一篇:strtok ()core dump
下一篇:我的代码质量
登录 注册