hello. i am working on a program, where i need the user to enter a password, which is then stored to a string. but, i need the password to appear as asteriscks, not as plain text. there is a conio.h function called getch() which enabled me to do this, but only on windows.
under winodows, using the conio.h function getch(), the code would look something like this:
[tt]
#include <iostream>
#include <conio.h>
#include <string>
using namespace std
string input;
int i = 0;
char ch;
while ( (ch = getch()) != '\r' )
{
input.at(i) = ch;
cout << '*';
i++;
}
[/tt]
how could i accomplish the same in UNIX? i am running MacOS X 10.2, and using the free Project Builder dev tools which came with the system. I am also looking for a clrscr() function, that works on UNIX as well.
under winodows, using the conio.h function getch(), the code would look something like this:
[tt]
#include <iostream>
#include <conio.h>
#include <string>
using namespace std
string input;
int i = 0;
char ch;
while ( (ch = getch()) != '\r' )
{
input.at(i) = ch;
cout << '*';
i++;
}
[/tt]
how could i accomplish the same in UNIX? i am running MacOS X 10.2, and using the free Project Builder dev tools which came with the system. I am also looking for a clrscr() function, that works on UNIX as well.