char* message与char message[]所导致的core dump的问题
问题和这个url里说的一模一样
http://blog.chinaunix.net/uid-20519550-id-1655944.html
转发到此:
当 char* message="$GPGSV,2,1,07,07,79,048,42,02,51,062,43,26,36,256,42,27,138,42*71";
parse(message);就会core dump;
如果
char message[]="$GPGSV,2,1,07,07,79,048,42,02,51,062,43,26,36,256,42,27,138,42*71";
就正常了。
void parse( char* message )
{
char *pch;
//char *message1="hello-world";
printf( "can parse\n" );
pch = strtok( message,",*");
printf( "over" );
while( pch != NULL ){
printf( "%s\n", pch);
pch= strtok( NULL ,",*");
}
}
请问是怎么回事?