#include <stdio.h>
#include <string.h>
int main(void) {
char frutas[] = "banana,laranja,morango";
int tamanho
= strlen(frutas
); //isto funciona só para delimitador de 1 caractere char *token
= strtok(frutas
, ","); for (int i
= 0; i
< tamanho
; i
++) printf(token
[i
] == 0 ? "\\0" : "%c", token
[i
]); while(token != NULL) {
}
}
//http://pt.stackoverflow.com/q/190755/101
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KCmludCBtYWluKHZvaWQpIHsKICAgIGNoYXIgZnJ1dGFzW10gPSAiYmFuYW5hLGxhcmFuamEsbW9yYW5nbyI7CiAgICBpbnQgdGFtYW5obyA9IHN0cmxlbihmcnV0YXMpOyAvL2lzdG8gZnVuY2lvbmEgc8OzIHBhcmEgZGVsaW1pdGFkb3IgZGUgMSBjYXJhY3RlcmUKICAgIGNoYXIgKnRva2VuID0gc3RydG9rKGZydXRhcywgIiwiKTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgdGFtYW5obzsgaSsrKSBwcmludGYodG9rZW5baV0gPT0gMCA/ICJcXDAiIDogIiVjIiwgdG9rZW5baV0pOwogICAgd2hpbGUodG9rZW4gIT0gTlVMTCkgewogICAgICAgIHByaW50ZigiXG4lcyIsIHRva2VuKTsKICAgICAgICB0b2tlbiA9IHN0cnRvayhOVUxMLCAiLCIpOwogICAgfQp9CgovL2h0dHA6Ly9wdC5zdGFja292ZXJmbG93LmNvbS9xLzE5MDc1NS8xMDE=