fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h> // <=========== faltava este include
  4. #define Nome "nome"
  5. #define TAM_STRING 12
  6.  
  7. int main(void) { // <========== o retorno aqui precisa ser um int
  8. char * str = malloc(TAM_STRING); // <======= a declaração pode e deve ser mais simples
  9. if (str == NULL) printf("Não já espaço para alocar");
  10. else {
  11. strcpy(str, Nome); // <======= acredito que queria usar esta função, não tinha o nome dela
  12. int tamanho = strlen(Nome);
  13. printf("Nome=[%s] tem [%d] caracters", str, tamanho);
  14. for (int i = 0; i < tamanho; i++) {
  15. printf("\nCaracter[%d] = [%c]\n", i , str[i]);
  16. if (str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u') printf("Vogal");
  17. }
  18. free(str);
  19. }
  20. }
  21.  
  22. //https://pt.stackoverflow.com/q/58741/101
Success #stdin #stdout 0s 4396KB
stdin
Standard input is empty
stdout
Nome=[nome] tem [4] caracters
Caracter[0] = [n]

Caracter[1] = [o]
Vogal
Caracter[2] = [m]

Caracter[3] = [e]
Vogal