getLine
returns the array which store char of standard input. I try to print out the string in the array only get some other character, not the input. What is wrong with the function?
char *file_name;
file_name = getLine("enter the file name");
printf("%s\n", file_name);
char *getLine(char *question){
printf("%s\n", question);
char c, answer[100];
int i = 0;
c = getchar();
while (c != '\n'){
answer[i++] = c;
c = getchar();
}
answer[i] = '\0';
return answer;
}