Interview Question
Country: United States
You can maintain 2 strings, one string you will append real characters, in another string you will add *. so for display you can * string, for validation of password, you can use real string.
I may be not understanding the problem. you can give more details.
char c;
std::string s;
for ( ;(c = getch()) && c != 13 ; )
{
s.push_back(c);
putch('*');
}
printf("\n%s to verify the logic...",s.c_str());
ofcourse 13 is value for \n
What is "std::string s;"?
I've been coding for a while but never seen a coding of this sort? Where can I find more info on this?
Thanks in advance.
That represents a c++ string class. :: is used as a scope resolution operator and string is a class in std namespace in c++
Instead of thinking in code think in words: you want to turn echoing off from a terminal or console. Echoing is a concept where input scanned from the keyboard is displayed on screen. You can turn this on (usually on by default) or turn it off. Under *nix based operating systems, curses is the usual choice for manipulating terminal properties.
use curses.h or ncurses.h
compile:
- nz2324nz2324 October 17, 2012