You can do this, but it will be something very system specific depending on your operating system and other factors. There are libraries that may do what you want such as "curses", which you could look into. To demonstrate the sort of hackery involved, I wrote something that works on my Ubuntu laptop. Running this may mess up your terminal settings, particularly if you break out mid program. I can use the "reset" command to fix that on Ubuntu or just reopen the terminal window.
#include <termios.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#define MAX_LENGTH 20
int main()
{
struct termios t, backup;
tcgetattr(STDIN_FILENO, &t);
backup=t;
cfmakeraw(&t);
tcsetattr(STDIN_FILENO, TCSANOW, &t);
char c=0;
int position = 0;
char password[MAX_LENGTH+1] = {0};
while (position<MAX_LENGTH)
{
c = getchar();
if (c<0x20)
break;
password[position++] = c;
putchar ('*');
}
tcsetattr(STDIN_FILENO, TCSANOW, &backup);
printf("\nPassword is : %s\n", password);
}