Author: Not specified Language: text
Description: Not specified Timestamp: 2013-05-26 20:28:34 +0000
View raw paste Reply
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main ()
  5. {
  6.   char str[] = "This";
  7.   //char str[] = "This,,,is,my,name,";
  8.   char * pch;
  9.   char * str1=str;
  10.   char * ptr = str1;  
  11.   while (ptr != NULL)
  12.   {
  13. //      printf("HERE\n");
  14.      pch=strchr(ptr,',');
  15.      //*pch++ = 0;
  16.     if(ptr != NULL)
  17.     {
  18.         if(pch != NULL){
  19.         *pch++=0;
  20.         }
  21.         printf("ptr is %s\n",ptr);
  22.      printf("pch is %s\n",pch);
  23.      }
  24.     else
  25.         break;
  26. ptr = pch;
  27.   }
  28.  
  29.   printf("current str is %s\n",str);
  30.   return 0;
  31. }
View raw paste Reply