首 页 | 新 闻 | Symbian | Android| Windows Mobile | J2ME | 下载中心 | 游戏策划招聘与求职 | 购书指南 | 视频教程
您现在的位置: 开发视界 >> Symbian >> 语言基础 >> 正文
如何实现“Press any key to continue...”
作者:佚名    文章来源:转载    更新时间:2007-9-3 9:46:29
---------------------------------------------------------------------------

Windows 下:

#include <stdio.h>
#include <conio.h> /* For getch(), non-portable. */

int main(int argc, char *argv[])
{
    printf("Press ENTER to continue...");
    getch();

    return 0;
}

---------------------------------------------------------------------------

Linux 下:

法一:

#include <stdio.h>
#include <termios.h>
#include <unistd.h>

/* Please reference the manpage (man termios) for more details. */

int mygetch(void)
{
    int ch;
    struct termios oldt;
    struct termios newt;

    tcgetattr(STDIN_FILENO, &oldt);
    newt = oldt;
    /*
     * Unset the CANONICAL mode, in which input is available immediately,
     * and the ECHO mode.
     */
    newt.c_lflag &= ~(ICANON | ECHO);
    tcsetattr(STDIN_FILENO, TCSANOW, &newt);
    ch = getchar();
    tcsetattr(STDIN_FILENO, TCSANOW, &oldt);

    return ch;
}

int main(int argc, char * argv[])
{
    printf("Press any key to continue...\n");
    mygetch();

    return 0;
}

法二:(会清屏,不如法一)

#include <ncurses.h>
#include <unistd.h>

int main(int argc, char * argv[])
{
    initscr();
    mvprintw(5, 5, "Press any key to continue...");
    getch();
    endwin();

    return 0;
}

---------------------------------------------------------------------------


参考:
1. http://www.timectrl.net/bbs/viewthread.php?tid=54
2. http://www.linuxsir.org/bbs/printthread.php?p=232994
相关文章:
没有相关文章
 

站点地图 | 加入收藏 | 联系站长 | 广告服务 |
QQ:280529124  Tel:0592-8271361 辽ICP备05021703号