When I call the function malloc
, I have allocated space only for char
, but it works for words of any size, so I was confused.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
char *palavra;
palavra = malloc(sizeof(char));
printf("Informe a palavra\n");
scanf("%s", palavra);
printf ("%d", conta_vogais(palavra));
}
int conta_vogais (char* s){
int tamanho = strlen(s);
char *vogais = {"aeiouAEIOU"};
int i, j, count = 0;
for(i = 0; i < tamanho; i++){
for(j = 0; j < strlen(vogais); j++){
if(s[i] == vogais[j]){
count++;
continue;
}
}
}
return count;
}