C PROGRAM TO ECHO "*" - C PROGRAM TO GET PASSWORD FROM USER

How to Enter Password in C language:
  Have you ever wondered how you can echo '*' when user input sensitive information in C, Same as we observe in a webpage by just typing:

<input type = "password"/>

Now, Doing the same in C is also simple i just wondered how to do that and came up with solution
 
#include <stdio.h>
#include <conio.h>

void main(){
      char pass[100];
      int i = 0;
       do{
            pass[i] = getch();
            if(pass[i]  == '\n'){
                    break;                // if user press enter it breaks the loop..
            }
            printf("*");
            i++;
       } while(1); // Always true You can put your condition here..
}
If you like my code then feel free to comment your feedback and share  & subscribe this post.
KUDOS!!

Comments

  1. Great explanation of how to handle input and echo characters in C! I especially liked the part about masking the password input—it’s simple yet effective for beginners learning secure input handling. As someone who usually works with different programming languages, I can see how concepts like these translate across languages. For instance, while tackling my ruby assignment help, I found similar techniques for input validation and user prompts really helpful. Posts like this make it easier to grasp fundamentals and apply them in other programming tasks.

    ReplyDelete

Post a Comment

Popular posts from this blog

NPTEL Introduction to programming in c Assignment 4 solutions

Code to Implement Dynamic Queue in C++ using arrays