int prompt(const char *output_message, char *input, const int MAX_SIZE)
{
printf("%s", output_message);
int i = 0;
char ch = '\0';
while (1)
{
ch = (char)getchar();
if (ch == '\n' || ch == EOF)
{
break;
}
else if (i < (MAX_SIZE - 1))
{
input[i++] = ch;
}
}
input[i] = '\0';
return i;
}
I wrote this function to get an input string input from the user. So getchar(), is going through the buffer until it reaches a newline or the end of the file. My question is does flushing the input buffer mean to move the FILE pointer(or whatever implementation is there) away from the currently written part in the buffer like I'm doing with getchar()? What does it actually mean to "flush the input buffer"?