Hide user input, and only allow certain characters

后端 未结 2 1878
执念已碎
执念已碎 2021-01-15 03:39

Is there any way to hide user input when asked for in C? For example:

char *str = malloc(sizeof(char *));
printf(\"Enter something: \");
scanf(\"%s\", str);g         


        
2条回答
  •  误落风尘
    2021-01-15 04:23

    For the sake of completeness: There is no way to do this in C. (That is, standard, plain C without any platform-specific libraries or extensions.)

    You did not state why you wanted to do this (or on what platform), so it's hard to make relevant suggestions. You could try a console UI library or a GUI library. You could also try your platform's console libraries. (Windows, Linux)

提交回复
热议问题