I have code that prompts the user for a filename, then displays the contents of the file on the console. However, the printf() statement I use won't print out until the very end, so the user doesn't know to input a filename.
int main(int argc, char * argv[]){
printf("%s", "What file would you like to open?\t");
char filename[100];
scanf("%[^\n]", filename);
printf("You chose:\t%s\n", filename);
return 0;
}
The program currently scans the console, then prints out both printf() statements. The scanf() statement works correctly, just not at the right time. Any idea what my problem is?
EDIT: the program works correctly when run from the command line, but the problem persists in Eclipse.