No conio.h has been resolved under Linux

Source: Internet
Author: User

Original: http://blog.sina.com.cn/s/blog_6a95e00b0100zqvf.html

#include <stdio.h>
#include <conio.h>

void Main () {
Char ch;
for (;;) {
System ("Stty-echo");
ch = getch ();
if (ch==27) break;
if (ch==13)
Continue
Putch (CH);
}
}

The Getch () feature in Linux implementation conio.h

The Getch () feature in the Conio.h header file is sometimes used when writing C programs under Windows, which reads keyboard characters but does not display (without echo)

Later found that the program containing conio.h in Linux could not be compiled through, because Linux does not have this header file, today suddenly found that can be replaced by other methods, posted out

In Windows

#include <stdio.h>

#include <conio.h>

int Mian () {

char c;

printf ("Input a char:");

C=getch ();

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

return 0;

}

In Linux

#include <stdio.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;

}

This will do, note: Linux Stty-echo is not to display the meaning of the input content

No conio.h has been resolved under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.