QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1867|回复: 0

求助--如何实现终端历史命令上下翻功能

[复制链接]
发表于 2006-8-29 00:06:00 | 显示全部楼层 |阅读模式
用C语言怎么实现像终端那种, 当按 KEY_UP时, 会显示上一次输入的命令的程序?
我自己想的代码如下, 可是不能实现:
[code:1]
#include <stdio.h>
                                                                                
int main(void)
{
    char *strs[] = {"String1", "String2"};
    char input[10];
                                                                                
    printf("Please Input a word:");
    fprintf(stdin, "%s", strs[0]);
    fflush(stdin);
                                                                                
    fscanf(stdin, "%s", input);
    printf("Input is %s\n", input);
                                                                                
    return 0;
}[/code:1]
您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-6-26 10:37 , Processed in 0.110307 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表