I found this code fragment with google, but the output is "Input [__]".
input_buf contains "test\n" according to the debugger, which is what I entered.
Any idea why this isn't working?
My goal is to ask the user a question (via the command line) and evaluate the response.
Thanks
input_buf contains "test\n" according to the debugger, which is what I entered.
Any idea why this isn't working?
My goal is to ask the user a question (via the command line) and evaluate the response.
Thanks
Code:
char input_buf[64] = {0};
char data[64] = {0};
printf("Enter something: ");
while( fgets(input_buf, sizeof(input_buf), stdin) == NULL )
{
/* parse the input entered */
sscanf(input_buf, "%s", data);
}
printf("Input [_%s_]\n", data);