Скрыть пользовательский ввод и разрешить только определенные символы

Есть ли способ скрыть пользовательский ввод при запросе в C? Например:

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

// This program would show you what you were writing something as you wrote it. 
// Is there any way to stop that?

Другое дело, как можно разрешить только определенные символы? Например:

char c;
printf("Yes or No? (y/n): ");
scanf("%c", &c);getchar();
printf("\nYou entered: %c", c);

// No matter what the user inputs, it will show up, can you restrict that only 
// showing up if y or n are entered?

Ответы на вопрос(2)

Ваш ответ на вопрос