| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have programmed a C++ Win32 Console Application that uses the scanf() function to get user input.
I was wondering if there was a way to set a default value (a string of course) for the scanf() function. That way, the user could simply hit enter if the default value is appropriate, or delete the default value and type in something different. I have tried writing to the stdin stream, but that didn't work. Is it even possible? Thanks! |
|
#2
|
|||
|
|||
|
I don't know of any way to do this in the console, unfortunately. If you really need this functionality, you'll have to go into Win32API programming with dialog boxes and edit controls and such.
One way I thought of to do something similar to what you want: Tell the user the default value (as in write it to stdout) and then take their input. If their input is some special value (say a space " ") then use the default value. Otherwise, use whatever the user inputted. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Default value for scanf() function. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|