![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 | |
|
Programmer
Join Date: May 2005
Posts: 48
Rep Power: 0
![]() |
Quote:
9 C:\C projects\password maker2.cpp `getpass' undeclared (first use this function) Please help me because i really want to use thsi little script for a personal program... ![]() |
|
|
|
|
|
|
#12 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Show YOUR code, not Jim's clip. You have to have unistd.h available for inclusion as well as correct spellings and definitions
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#13 | |
|
Professional Programmer
Join Date: Jun 2005
Location: India, The great.
Posts: 435
Rep Power: 4
![]() |
Quote:
so the max. subscript is 9. 1 char is reserved for null terminator. so the count variable should not go beyond 8. if(count>7) precisely specifies this. I should have made this clear earlier. But i thought it was straight-forward .
__________________
PFO - My daily dose of technology. |
|
|
|
|
|
|
#14 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
You're right, of course. That'll teach me to read output and comments instead of declarations! :o
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#15 | |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
Quote:
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
|
#16 |
|
Newbie
Join Date: Jun 2005
Location: far..far..away
Posts: 25
Rep Power: 0
![]() |
You should make the array have a constant 10.
#define MAX 10 char pass[MAX]; ... just a thought |
|
|
|
|
|
#17 |
|
Newbie
|
Hi NavNav,
I have made small changes in u r code. Try this one. It is working fine. #include <stdio.h> #include <conio.h> #include <stdlib.h> char pass[10]; int count=0; int main(void) { printf("Enter new password (10 characters max):"); while ( (pass[count++]=getch()) != '\r') { if(count > 10) { for (count=0; count<10; count++) { pass[count] = '\0'; } printf("\n\nYour password is too long, enter it again:"); count = 0; continue; } else { if (pass[count-1] == '\b' && count==1) { count=0; continue; } else { if (pass[count-1] == '\b') { printf("\b"); printf(" \b"); count -= 2; } else { printf("*"); } } } } puts("\n\nYour new password is:");puts(pass); printf("\n"); system("pause"); return 0; } I u have any doubts, send mail to me. |
|
|
|
|
|
#18 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
You can post in [code] tags. Which preserves indenting.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
#19 |
|
Newbie
|
#include <stdio.h>
#include <conio.h> #include <stdlib.h> char pass[10]; int count=0; int main(void) { printf("Enter new password (10 characters max):"); while ( (pass[count++]=getch()) != '\r') { if(count > 10) { for (count=0; count<10; count++) { pass[count] = '\0'; } printf("\n\nYour password is too long, enter it again:"); count = 0; continue; } else { if (pass[count-1] == '\b' && count==1) { count=0; continue; } else { if (pass[count-1] == '\b') { printf("\b"); printf(" \b"); count -= 2; } else { printf("*"); } } } } puts("\n\nYour new password is:");puts(pass); printf("\n"); system("pause"); return 0; } I have tested in VC++ editor. this is working fine.............. |
|
|
|
|
|
#20 | |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4
![]() |
Quote:
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand." - B. Russell http://web.bryant.edu/~srk2 |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|