I'm writing a program that can take computer specifics from the user in manual mode. However, I've run into a bit of a problem.
In this code:
char choice = getc(stdin);
if (choice == 'y' || choice == 'Y')
{
config_file = fopen(config_file_loc, "w");
printf("%s", "Please enter the name of your distribution/OS: ");
fgets(distro_str, MAX_STRLEN, stdin);
fputs(distro_str, config_file);
fputs("\n", config_file);
printf("%s", "Please enter your architecture: ");
fgets(arch_str, MAX_STRLEN, stdin);
fputs(arch_str, config_file);
fputs("\n", config_file);
fclose(config_file);
}
During runtime, the input jumps right from "Please enter the name of your distribution/OS:" to "Please enter your architecture:", leaving distro_str blank.
I've tried flushing stdin and stdout, but those haven't worked.
Thanks for your help.