After compiling the program, you receive 2 warnings of the same type:
"warning: 'phrase is used uninitialized in this function"
and
"warning: 'word' is used uninitialized in this function"
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char *alocar_palavra(char *palavra);
char *alocar_frase(char *frase);
int main(){
char *frase, *palavra;
frase = alocar_frase(frase);
palavra = alocar_palavra(palavra);
printf("%s", frase);
printf("%s", palavra);
return 0;
}
char *alocar_palavra(char *palavra){
palavra = (char*)malloc(20 * sizeof(char));
scanf(" %s", palavra);
return palavra;
}
char *alocar_frase(char *frase){
char letra;
int k = 0;
frase = NULL;
do{
letra = getchar();
frase = (char*)realloc(frase, (k+1)*sizeof(char));
frase[k] = letra;
k++;
}while((letra != '$') && (letra != '\n'));
return frase;
}