Tronquer une chaîne de caractères à l’aide d’un séparateur avec ‘strtok()’

Author:


Download

 
#include 
#include 
 
int main ()
{
  char str[] ="Apprendre à programmer en C/C++.n";
  char *token;
 
  printf ("La chaîne '%s' en morceaux:", str);
 
  //Découper la chaîne selon les espaces
  token = strtok (str," ");
 
  //Afficher le résultat du découpage
 
  while (token != NULL)
  {
    printf ("%sn", token);
    token = strtok (NULL, " ,");
  }
  return 0;
}