#include <stdio.h>
#include <string.h>
int main(void) {
char entrada[100]; // Para obter até 100 caracteres da entrada
int qtdEspacos = 1;
int i = 0;
if(fgets(entrada
, sizeof entrada
, stdin
) != NULL
) { char *ptr = entrada;
while((ptr
= strchr(ptr
, ' ')) != NULL
) { // Se encontrou espaço qtdEspacos++;
ptr++;
}
// Cria o array com tamanho baseado na quantidade de espaços na string
int * elementos[qtdEspacos];
for (char *pedaco
= strtok(entrada
, " "); pedaco
!= NULL
; pedaco
= strtok(NULL
, " ")) { elementos[i++] = pedaco;
}
for (int n = 0; n < qtdEspacos; ++n) {
printf("Indice [%d] = %s\n", n
, elementos
[n
]); }
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KCmludCBtYWluKHZvaWQpIHsKCWNoYXIgZW50cmFkYVsxMDBdOyAgLy8gUGFyYSBvYnRlciBhdMOpIDEwMCBjYXJhY3RlcmVzIGRhIGVudHJhZGEKCWludCBxdGRFc3BhY29zID0gMTsKCWludCBpID0gMDsKCQoJaWYoZmdldHMoZW50cmFkYSwgc2l6ZW9mIGVudHJhZGEsIHN0ZGluKSAhPSBOVUxMKSB7CgkJY2hhciAqcHRyID0gZW50cmFkYTsKCQkKCQl3aGlsZSgocHRyID0gc3RyY2hyKHB0ciwgJyAnKSkgIT0gTlVMTCkgeyAvLyBTZSBlbmNvbnRyb3UgZXNwYcOnbwoJCQlxdGRFc3BhY29zKys7CgkJCXB0cisrOwoJCX0KCQkKCQkvLyBDcmlhIG8gYXJyYXkgY29tIHRhbWFuaG8gYmFzZWFkbyBuYSBxdWFudGlkYWRlIGRlIGVzcGHDp29zIG5hIHN0cmluZwoJCWludCAqIGVsZW1lbnRvc1txdGRFc3BhY29zXTsKCQkKCQlmb3IgKGNoYXIgKnBlZGFjbyA9IHN0cnRvayhlbnRyYWRhLCAiICIpOyBwZWRhY28gIT0gTlVMTDsgcGVkYWNvID0gc3RydG9rKE5VTEwsICIgIikpIHsKCQkJZWxlbWVudG9zW2krK10gPSBwZWRhY287CgkJfQoJCQoJCWZvciAoaW50IG4gPSAwOyBuIDwgcXRkRXNwYWNvczsgKytuKSB7ICAgIAoJCQlwcmludGYoIkluZGljZSBbJWRdID0gJXNcbiIsIG4sIGVsZW1lbnRvc1tuXSk7CgkJfQoJfQoJcmV0dXJuIDA7Cn0K