No, scanf () cannot be accepted for accepting "default values". You should get the input, check it for empty and set the default value yourself.
As you found out, scanf () is harder; I agree with extraneon that fgets () is probably what you are looking for.
Edit:
The reason why scanf () does not respond ... scanf () returns after it a) processed all conversion specifiers or b) found an error. As with all conversion qualifiers ("% s" in this case), missing spaces are skipped. In addition, "% s" reads all characters to the next space.
Hit return inserts '\ n' into standard input. So, if you hit return before you type anything else (except maybe a few tabs and spaces), scanf () will skip your input and continue to wait for input without spaces.
Whatever you enter, scanf () will not βseeβ it until you hit return, because your input is stored in the console buffer. (Otherwise, you would not be able to go back through your input.) Pressing again returns "\ n" to the input stream, so your "% s" ends even if you did not enter any tabs / spaces on the line that you dialed.
If you enter spaces, your cMountDrivePath will only contain the first βwordβ before the first space, so leaving spaces in the directory or file names makes those damn annoying. It would also leave the rest of the line in the input buffer, so the next time you call scanf (), it wonβt immediately ask for input, but proceed with processing what was buffered during the previous call β another annoying detail for scanf () newcomers to follow.
Hope this makes it a little easier for you (and other people yet to come).
source share