歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> 關於Linux下conio頭文件的實現

關於Linux下conio頭文件的實現

日期:2017/3/1 9:17:03   编辑:Linux編程

在Windows下,c語言有庫conio.h,實現了不少函數,但是Linux C沒有這個庫,內部的函數需要自己實現。

//clrsrc清屏函數的一種實現:<br>void clrscr(void)

{

  system("clear");//需要頭文件stdlib.h

}

//調用system("clear")

//getch()函數的一種實現方法<br>#include<stdio.h>

#incldue<stdlib.h>

int main(){

char c;

printf("Input a char:");

system("stty -echo");

c=getchar();

system("stty echo");

printf("You have inputed:%c \n",c);

return 0;

}

//這裡調用了system("stty -echo")和system("stty echo")實現對其中的輸入不現實出來


還有一些這個頭文件下其他的函數沒有實現,歡迎大家添加!如有錯誤,歡迎指正。

Copyright © Linux教程網 All Rights Reserved