Created
August 2, 2019 22:08
-
-
Save parzibyte/bc317b4abdfc8cb6cd11819a9e37fd14 to your computer and use it in GitHub Desktop.
Más delimitadores con strtok en C - https://parzibyte.me/blog/2018/11/13/separar-cadena-delimitadores-c-strtok
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
int main(){ | |
char cadena[] = "Esto es un texto. Puede ir separado por puntos, espacios o comas.", | |
delimitador[] = ",. "; | |
char *token = strtok(cadena, delimitador); | |
if(token != NULL){ | |
while(token != NULL){ | |
// Sólo en la primera pasamos la cadena; en las siguientes pasamos NULL | |
printf("Token: %s\n", token); | |
token = strtok(NULL, delimitador); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment