#include #include #include int mygetch ( void ); void getpwd ( char *password ); int main() { char password[255] = { 0 }; getpwd ( password ); /* Dalje radiš šta te volja sa unesenim passwordom */ return 0; } /* This is the getch() function for linux systems */ int mygetch(void) { struct termios oldt, newt; int ch; tcgetattr( STDIN_FILENO, &oldt ); newt = oldt; newt.c_lflag &= ~( ICANON | ECHO ); tcsetattr( STDIN_FILENO, TCSANOW, &newt ); ch = getchar(); tcsetattr( STDIN_FILENO, TCSANOW, &oldt ); return ch; } void getpwd ( char *password ) { int counter = 0; printf("Enter password: "); /* Repeat until Return is pressed */ while ((password[counter] = mygetch()) != 10) { /* Check if special character is pressed */ if ( password[counter] == 127 ) { /* Backspace */ if (counter > 0) { printf("%c%c%c", 8, ' ', 8); --counter; } } else { printf("*"); ++counter; } } password[counter] = '\0'; /* Postavlja null string na kraju passworda */ printf("\n"); /* Ispisuje newline na kraju unesenog passworda */ }