May 13, 2012 at 5:25pm UTC
Hi :)
I was trying to figure out, how to mask password input with '*'. And I found this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#include <iostream>
#include <conio.h>
using namespace std;
int main(){
string pass;
char ch;
cout << "Enter pass\n" ;
ch = _getch();
while (ch != 13){
pass.push_back(ch);
cout << '*' ;
ch = _getch();
}
if (pass == "mypass" ){
cout << "\nAccess granted :P\n" ;
}else {
cout << "\nAccess aborted...\n" ;
}
}
since I'm Mac user, that's not really for me, so I tried ncurses.h with getch() and get weird error, well, weird for me as a beginner:
1 2 3
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [password] Error 1
What can I do with this to make it run.
and btw, I'm using Eclipse IDE for C/C++ Developers for Mac, if it helps :)
Last edited on May 17, 2012 at 3:04pm UTC
May 13, 2012 at 5:52pm UTC
I don't insist :) It's just native to see password as asterisks :P
I work in linux too, so I'm used to "see" nothing as pass too :P
I'll check those you sent me.
May 13, 2012 at 5:56pm UTC
I don't really understand that code you've sent me :/
May 14, 2012 at 12:28pm UTC
It looks like the linker can't find something that it needs...is there any output prior to the 'ld: symbol(s) not found ' output?
Last edited on May 14, 2012 at 12:29pm UTC
May 15, 2012 at 5:32pm UTC
I don't know :/ I'm new at this :/
May 15, 2012 at 7:57pm UTC
Did you forget to link with -lcurses ?
May 17, 2012 at 2:48pm UTC
I don't know what that is... :/
Pls help me
May 17, 2012 at 3:24pm UTC
error: 'nullptr' was not declared in this scope
:/
May 17, 2012 at 3:27pm UTC
nullptr is only available on new compilers. Use 0 or NULL instead.
May 17, 2012 at 3:27pm UTC
nullptr is only available in C++11. It is generally better to test pointers by making use of the implicit conversion to bool anyway, so shorten it to phrase? ... .
May 17, 2012 at 3:38pm UTC
well, no error now, but It didn't asked me to enter anything :/ just typed: error reading pass phrase
May 17, 2012 at 4:02pm UTC
a. Run the program as it is from the command line.
b. Remove the forced read only frrom/dev/tty (ignore stdin) option - replace RPP_REQUIRE_TTY with 0
And tell us what happens.
May 17, 2012 at 4:23pm UTC
I don't have command line :) I use Eclipse :)
May 17, 2012 at 4:27pm UTC
I guarantee you that you have a command line.