fork(1) download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #define TRENNZEICHEN "/"
  5.  
  6. int main ()
  7. {
  8. char str[] ="BT9/Raum903/PC10/;";
  9. char * pch;
  10. char * pFelder[5];
  11. int j=0;
  12.  
  13. printf ("Str: \"%s\" \n",str);
  14. pch = strtok (str,TRENNZEICHEN);
  15. pFelder[j++] = pch;
  16. while (pch != NULL)
  17. {
  18. //printf ("%s\n",pch);
  19. pch = strtok (NULL, TRENNZEICHEN);
  20. pFelder[j++] = pch;
  21. }
  22. for(int i=0; i < j-2; i++) {
  23. printf ("%s \n",pFelder[i]);
  24. }
  25. return 0;
  26. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
Str: "BT9/Raum903/PC10/;" 
BT9 
Raum903 
PC10