Password input solution under Linux console

Source: Internet
Author: User

In the Linux system coding C language Program of the code farm should know, its and in Windows programming is very different, there is not many Linux under Windows commonly used header files, but there are many windows do not have a header file, for beginners, there is a certain restrictive, For example, conio.h header file, there are many functions we often use, so we in the windows under a small system, the common login link can not be used under Linux, today, I will help you solve this problem.

1 #include <stdio.h>

2 Char getch ()
3 {
4 char C;
5 System ("Stty-echo");
6 System ("Stty-icanon");
7 C=getchar ();
8 System ("Stty Icanon");
9 System ("Stty echo");
Ten return C;
11}
void Main ()
13 {
int i;
(+ char a[21];
-Char ch;
+ printf ("Please enter password:");
for (i=0;i<20;i++)
19 {
Ch=getch ();
if (ch== ' \ n ')
22 {
a[i]= ' + ';
break;
25}
Putchar (' * ');
A[i]=ch;
28}
if (i==20)
"A[20]=";
printf ("%s\n", a);
32}

Password input solution under Linux console

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.