ungetch

ungetch的功能是把一個字元退回到鍵盤緩衝區中。

在較高版本的一些Visual Studio編譯器中(如vs2015),ungetch 被認為是不安全的,應當該使用 _ungetch 代替 ungetch 。

基本介紹

  • 中文名:ungetch
  • 性質:函式名
  • 用 法:: int ungetch(int c);
  • 領域:編程
函式名: ungetch
用 法:int ungetch(int c);
程式例:
#include <stdio.h>#include <conio.h>#include <ctype.h>int main( void ){    int i=0;    char ch;    puts("Input an integer followed by a char:");    /* read chars until non digit or EOF */    while((ch = getch()) != EOF && isdigit(ch))        i = 10 * i + ch - 48; /* convert ASCII into int value */    /* if non digit char was read, push it back into input buffer */    if (ch != EOF)        ungetch(ch);    printf("\n\ni = %d, next char in buffer = %c\n", i, getch());    return 0;}

相關詞條

熱門詞條

聯絡我們