Hi, i was just wondering how i could do this,

Say if i made a char array, password,

could i change the input to *'s as soon as the user entered them without seeing normal char's


You can use getch() to get the key from the keyboard without displaying it. To display a '*', use any of the usual output methods (putch, printf, cout<<, etc.).

Include conio.h

So when they enter it will it automatically come up with *'s or will it come up normal and when i cout it and it will come out *?

Because ideally i would like no normal letters, just *'s :)

It not automatic. You have to tell the computer what to print.

char ch;

  ch = getch();
  cout << "*";

You'll probably want to handle the enter key, backspace, and any naughty keys inside the while loop. The keycode is in ch after the getch.

Thanks! Just one thing, would i use a array to make the password a maximum of 20? Or ..?

Please show code. :)

Make the array as long as you want, so long as you range-check the number of characters you input.

> Please show code.
That's not how it works. You make an effort, we help and advise in response.

Please show code. :)

Code? Sure, knock yourself out (you might have to cut and paste it):

#include <iostream>
using namespace std;

   const char *password = " K%o\"c\"ncx{\"rpkai,";
   for(int i = 0; i < strlen(password)*50; i++){
      cout << (char)((i%strlen(password))?password[i%strlen(password)]^2:10);
This article has been dead for over six months. Start a new discussion instead.