写一个函数讲一个字符串使用特定的分隔符分割后输出

#include <stdio.h>

int main(){
  char* p = NULL;
  char s[100] ;

  int i = 0;

  scanf("%s",s);
  p = s;
  printf("%s\n",p);
  char a ;
  int count = 0 ;

  while((a = *p++) !='\0'){
      if(a ==':'){
         count++;
      }
  }

  p = s;

  int count1 = 0;
while((a = *p++)!='\0'){
    i++;

    if(a == ':'){
       count1++;


       int j ;
       for(j = -i; j < -1 ; ++j){
          printf("%c",p[j]);
       }
       printf("\n");

       if(count == count1){
           printf("%s\n",p);
           return 0;
       }

       i = 0;
    }

  }
}



posted @ 2013-07-19 19:33  坚固66  阅读(184)  评论(0编辑  收藏  举报