none
为什么使用strtok后问题,变量str不相同? RRS feed

  • 问题

  • 	char str[] ="now  #  is  the  time  for  all  #  good  men  to  come  to  the  #  aid  of  their  country";
    	char strTemp[100]="";
    	printf("str is %s\n",str);
    	strcpy(strTemp,str);
    	printf("str=%d\n",str);
    	printf("strTemp=%d\n",strTemp);
    	printf("tempstr is %s\n",strTemp);
    	char delims[] = "#";
    	char* result = NULL;
    	result = strtok(strTemp,delims);
    	while(result != NULL)
    	{
    		printf("result is \"%s\"\n",result);
    		printf("tempstr is %s\n",strTemp);
    		result = strtok(NULL,delims);
    	}
    	printf("str=%d\n",str);
    	printf("str is %s\n",str);
    
    <br/>
    
    <br/>
    
    2011年2月18日 5:37

答案

全部回复