C command-line password input

后端 未结 7 851
长情又很酷
长情又很酷 2020-12-03 15:00

I want to allow users to enter password using command-line interface. but I don\'t want to display this password on screen (or display \"****\").

How to do it in C?

7条回答
  •  甜味超标
    2020-12-03 15:14

    If your system provides it, getpass is an option:

    #include 
    /* ... */
    char *password = getpass("Password: ");
    

    This will not display anything as characters are typed.

提交回复
热议问题