0

I have a C code, which prompts users for list of directory name, it just uses plain scanf() to receive the input and proceeds. Now I would like to provide autocomplete for directory names (like bash does). Say user enter /home/a and press TAB - it displays list of available user directories that begins with 'a'.how to achieve this?

4

1 回答 1

2

scanf不适用于内核熟模式终端驱动程序提供的基本级别(基本上只是退格)之外的任何类型的自动完成甚至交互式编辑。如果您想进行更高级的交互输入,则需要更改终端模式,以便获取每个关键事件并自己处理它们,或者您可以使用类似的库readline为您完成此操作。

于 2012-11-26T02:06:46.437 回答