Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 21st, 2004, 09:11 AM
Authorized User
 
Join Date: Jan 2004
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default c++ question

hello....i want to know the logic of the following question..
ok....i would like to write a program..that asks the user to enter his email address.....and enter his password...." when the user enters the password" it should be in the form of *******...then i would like to make the program shows the ****** in letters..

example: sample output

Enter your email.
name@name.com
Enter your password.
********

thanks
Your password is : name123

Reply With Quote
  #2 (permalink)  
Old February 24th, 2004, 03:35 AM
Registered User
 
Join Date: Feb 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Check the implementation for yor problem. The length of the UserName and Password are restricted to 10, but you may change it as you wish.

#include <stdio.h>
#include <conio.h>
main()
{
    char UserName[10], Password[10];
    printf("\nEnter User Name :");
    scanf("%s", UserName);
    printf("\nEnter Password :");
    char ch; int i=0;
    while((ch=getch())!=13)
    {
        Password[i] = ch;
        putch('*');
        i++;
    }
    Password[i] = '\0';

    printf("\nThanks\nYour Password is :%s\n", Password);
}

Venkat
Reply With Quote
  #3 (permalink)  
Old February 24th, 2004, 12:20 PM
Authorized User
 
Join Date: Jan 2004
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hello........please can you explain for me the step of the while statement...i got confused with that..

and thank for helping..i appreciate it

Reply With Quote
  #4 (permalink)  
Old February 24th, 2004, 02:45 PM
Friend of Wrox
 
Join Date: Feb 2004
Location: Bangalore, Karnataka, India.
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

While loop runs until you press the enter key, ASCII equivalent of enter key is 13.

Whenever you press a key in the keyboard it is stored in the variable ch, which is not echoed on the screen, because the function getch() won't display on the screen.

But we have putch('*') which will put * on the scree, for each key you are pressing.

Finally outside the while loop, you add the null character to end the string.

Regards
Pradeep

It is not how much we do,
but how much love we put in the doing.

-Mother Theresa
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question maheshraju ASP.NET 2.0 Basics 3 March 13th, 2008 08:54 AM
Question Ashwini Classic ASP Databases 3 January 10th, 2006 07:20 AM
Question? Calibus Classic ASP Databases 8 August 6th, 2004 08:25 AM
a question gorji C++ Programming 2 August 11th, 2003 07:41 AM



All times are GMT -4. The time now is 03:55 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.