关于Linux下conio头文件的实现

Linux大全评论721 views阅读模式

在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")实现对其中的输入不现实出来

企鹅博客
  • 本文由 发表于 2020年7月9日 18:33:51
  • 转载请务必保留本文链接:https://www.qieseo.com/133493.html

发表评论