All pastes #26507 Raw Edit

Miscellany

public text v1 · immutable
#26507 ·published 2005-10-24 18:22 UTC
rendered paste body
/* strtok example */
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
int main ()
{
  char str[] ="21 23";
  char * pch;
  int a,b;
  printf ("Splitting string \"%s\" in tokens:\n",str);
  pch = strtok (str," ");
  while (pch != '\0')
  {
    a=atoi(pch);
    pch = strtok ('\0', " ");
   
    b=atoi(pch);    
    pch = strtok ('\0', " ");
        
  }  
  printf ("%d\n",a);
  printf ("%d",b);
  getch();
  return 0;
}