Created
August 2, 2019 22:07
-
-
Save parzibyte/0c0c911c7274c40c82f2d12bb9cee54b to your computer and use it in GitHub Desktop.
Split en C - Separar cadena - 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[] = "Hola,mundo,soy,una,cadena,separa,por,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