ncurses troubles
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > ncurses troubles




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    ncurses troubles  
Rob Somers


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-24-05 11:11 PM

I have been fiddling with ncurses, particularly with the material found in
the book 'Beginning Linux Programming, 3rd edition' - anyway, there is a
program on page 216 that I can't get to work properly.  Here is the code
that I believe is causing the trouble:


move(9, 10);
printw("%s", "Password: ");
refresh();

cbreak();
noecho();

memset(password, '\0', sizeof(password));
while (i < PW_LEN) {
password[i] = getch();
move(9, 20 + i);
addch('*');
refresh();
if (password[i] == '\n') {
break;
}
if (strcmp(password, real_password) == 0) {
break;
}
i++;
}

echo();
nocbreak();

move(11, 10);
if (strcmp(password, real_password) == 0) {
printf("%s", "Correct");
} else {
printf("%s", "Wrong");
}

refresh();
endwin();

return 0;
}

...in particular, the program executes (seemingly) properly until the
statements:
if (strcmp(password, real_password) == 0) {
printf("%s", "Correct");
} else {
printf("%s", "Wrong");
}

It does not print out anything at all.  I enter the password, and then the
program terminates.  I have stepped through the program with a debugger,
and when I enter the correct password, it indeed says 'Correct', but only
in the debugger.  Any help would be appreciated.

Rob Somers






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 08:49 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register