Just wondering how to echo user input (e.g. password) as asterisks?
Any suggestions plz?
Thom
Just wondering how to echo user input (e.g. password) as asterisks?
Any suggestions plz?
Thom
Before you criticise a man, walk a mile in his shoes. Then, when you criticise him, you're a mile away. And you have his shoes.
ive just answered this on the windows board. I hope you meant for windows....
Dont cross post... pick the forum that best will solve the problem and stick with it.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
Yeah sorry about that, I didn't actually mean to post it in the windows section.
I meant in DOS, can it be done?
I'm using Vis C++ 6, Win32 Console Application.
Cheers.
Before you criticise a man, walk a mile in his shoes. Then, when you criticise him, you're a mile away. And you have his shoes.
You can use getch() (in conio.h) to read characters without echo-ing them on the screen and then use cout<< or printf() to output an asterisk for every character read.
As an example:
Code:#include <iostream> #include <conio.h> const char ENTER = 13; int main() { char* str; char key; int i = 0; while(1) { key = getch(); if(key == ENTER) break; str[i] = key; std::cout << '*'; i++; } return 0; }
> char* str;
Uninitialised pointer alert!!!!!
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Hehe I thought that, and I'm a newbeh!
I'll give it a try though, thanks. Isn't there a simpler way?
Before you criticise a man, walk a mile in his shoes. Then, when you criticise him, you're a mile away. And you have his shoes.