在c ++中提示可编辑的默认值? [英] Prompt with editable default in c++?
问题描述
可以(不使用外部库,如boost)提示用户的输入,如使用cin,但使用用户可编辑的默认选项(没有GUI)?
Is is possible (without external library such as boost) to prompt for input from the user, like using cin, but with a default choice that is editable by the user (without a GUI)?
例如,程序会说:
Give your input: default
并且用户可以按回车键使用default default1等。
and the user can press enter to use "default" or press 1 then enter to get "default1", etc.
编辑:
我目前在程序中提供的默认在提示符(如下面的答案之一)。但我写的非常特殊的情况下,有一个可编辑的默认是极为节省时间(90%的时间,所有的用户需求是添加一个后缀到默认)。我可以提示仅使用后缀,但是我失去了在其他10%的情况下编辑默认值的灵活性。
What I current have in my program is providing the default in the prompt (as in one of the answer below). But I'm writing for very special cases where having a editable default is extremely time saving (and 90% of the time, all the user needs is adding a suffix to the default). I can prompt for the suffix only, but then I lost flexibility to edit the default in the other 10% of the cases.
推荐答案
您可以使用 GNU阅读式。
这篇关于在c ++中提示可编辑的默认值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!