 
 
 
 
 
   
在 BSD 中用 cbreak 模式,在 SysV 中則用 ICANON 模式。
如果你懶得用 "ioctl(2)" 來設定 terminal 的參數,也可以用 stty 來做, 不過有點慢又沒有效率就是了。底下的程式自己看著辦吧:
	      #include <stdio.h>
	      main()
	      {
        	    int c;
	            printf("Hit any character to continue\n");
        	    /*
	             * ioctl() would be better here; only lazy
        	     * programmers do it this way:
	             */
        	    system("/bin/stty cbreak");        /* or "stty raw" */
	            c = getchar();
	            system("/bin/stty -cbreak");
	            printf("Thank you for typing %c.\n", c);
	            exit(0);
	      }
	有好幾個人送給我更正確的解法。不過很抱歉我不想把它們加進去,因為這已經
	超出這份文件的範圍了。
通常對這個問題有興趣的人,都是想要做一些控制螢幕顯示之類的事情。如果你 也是的話,那請參考 "curses" 的相關文件。 "curses" 是一個 portable 的螢 幕控制函數庫。