2011年12月14日 星期三

Linux c Split 用法

#include <stdio.h>
#include <string.h>


int main ()
{
 char str[] ="a b c d*e";
 const char *split = " ";
 char *p;
 int i=0;
 p = strtok (str,split);
 while(p!=NULL)
 {
  if (i==1)
   printf ("%s\n",p);
   i++;
  p = strtok(NULL,split);
 }
 return 0;

沒有留言:

張貼留言