// compile as gcc pass.c -lcurses
#include <curses.h>
#include <stdio.h>

int main(void)
{
    // use the correct type, see https://linux.die.net/man/3/getch
    int k;

    // init curses:
    initscr();
    noecho();	// The typed letter is not shown.

    // in curses, you have to use curses functions for all terminal I/O
    addstr("Password: ");
    char pass[100];
    int iipass = 0;

    k = getch();
    while (k != '\n') {
	pass[iipass++] = (char)k;
	addstr("*");	// Can be removed.
    	k = getch();
    }
    pass[iipass] = '\0';

    // end curses:
    endwin();

    printf("You entered %s\n", pass);

    return 0;
}
