精品丰满熟女一区二区三区_五月天亚洲欧美综合网_亚洲青青青在线观看_国产一区二区精选

  • <menu id="29e66"></menu>

    <bdo id="29e66"><mark id="29e66"><legend id="29e66"></legend></mark></bdo>

  • <pre id="29e66"><tt id="29e66"><rt id="29e66"></rt></tt></pre>

      <label id="29e66"></label><address id="29e66"><mark id="29e66"><strike id="29e66"></strike></mark></address>
      學(xué)習(xí)啦 > 學(xué)習(xí)英語(yǔ) > 專業(yè)英語(yǔ) > 計(jì)算機(jī)英語(yǔ) > c語(yǔ)言中g(shù)etch的用法

      c語(yǔ)言中g(shù)etch的用法

      時(shí)間: 長(zhǎng)思709 分享

      c語(yǔ)言中g(shù)etch的用法

        getch()函數(shù)是無回顯的從控制臺(tái)取得一個(gè)字符。以利用getch()函數(shù)讓程序調(diào)試運(yùn)行結(jié)束后等待編程者按下鍵盤才返回編輯界面,即任意鍵繼續(xù)效果。下面小編就跟你們?cè)敿?xì)介紹下c語(yǔ)言中g(shù)etch的用法,希望對(duì)你們有用。

        c語(yǔ)言中g(shù)etch的用法如下:

        [cpp] view plain copy

        #include <stdio.h>

        #include <conio.h>

        int main()

        {

        int i ;

        i = getch();

        printf("press any key to continue\n");

        printf("%d\n", i);

        return 0;

        }

        Windows下getch()在conio.h的頭文件中,但conio.h不是標(biāo)準(zhǔn)庫(kù)文件,C standard library,ISO C 和POSIX標(biāo)準(zhǔn)中均沒有定義。固然Linux系統(tǒng)中會(huì)沒有這個(gè)頭文件,網(wǎng)上說在curses.h,然后下載一個(gè)庫(kù),但弄了半天也沒成功取得,從網(wǎng)上找到了一個(gè)方法實(shí)現(xiàn)getch()的功能。

        [cpp] view plain copy

        int getch()

        {

        struct termios tm, tm_old;

        int fd = STDIN_FILENO,c;

        if (tcgetattr(fd, &tm) < 0)

        {

        return -1;

        }

        tm_old = tm;

        cfmakeraw(&tm);

        if (tcsetattr(fd, TCSANOW, &tm) < 0)

        {

        return -1;

        }

        c = fgetc(stdin);

        if (tcsetattr(fd,TCSANOW,&tm_old) < 0)

        {

        return -1;

        }

        return c;

        }

        直接可以這樣用:

        [cpp] view plain copy

        /******************************************************************

        *描述: 實(shí)現(xiàn)任意鍵繼續(xù)

        *參數(shù): void

        *返回值: void

        *******************************************************************/

        void press_key()

        {

        printf("任意鍵繼續(xù)...\n");

        getch();

        }

        頭文件

        [cpp] view plain copy

        #include <stdio.h>

        #include <stdlib.h>

        #include <termios.h>

        #include <unistd.h>

      熱門文章

      522944