[英]Intelligent Editor program in C
编写一个智能编辑器来模拟以下内容:
在键入时,如果一个新单词的开头字母与之前输入的单词的字母相同,则应选择选择单词而不是键入整个单词。 这是我的功课。
我的算法:
1: Read the input by everytime checking the _kbhit() macro.
2: Store the word in an array
3: On every further read, check the array if the word exists.
现在出现问题!!!
如何为用户提供选择单词的选项? 即使提供选项成功,我怎么知道用户已决定选择该字?
我是这种编程风格的新手。 谁知道怎么做,请帮帮我...
各种各样的东西使用自动完成....甚至谷歌搜索! 您只需要选择一个方法,例如,选项卡循环选项,空格选择该选项(或输入)。 也许Esc阻止它试图自动完成该选项。 无论哪种方式,由你来制定计划。 也许尝试一些其他程序自动完成。
这取决于您如何阅读输入,并与用户进行通信。 如果它只是一个终端,我建议你定义一个键(可能是tab或esc)来移动到choosing state
,然后让他(例如)点击一个数字(或键)。
编辑:一些代码:
char c=getchar();
//some of your proccessing...
if (c=='\t') {
printf("\nPlease select option (0 to abort)\n");
char **op;
int n,i;
//calculate the options, assign them to op and n.
for (i=0;i<n;i++) printf("%d: %s\n",i+1;op[i]);
i=n+1;
while (i<0 || i>n) scanf("%d",&i);
if (i>0) {
//do whatever you need. remember to use i-1
}
}
//reprint the whole string.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.