How to make the number typed in keyboard to be displayed as "******" ?

Excuse me,may I ask one thing.. How to make the numbers that I type in the keyboard to be displayed as *****? Just like we usually enter a password,and it appear as *****.. What is the pseudocode to run as I mention above? By the way,I'm still a student..
I've read the forum,but actually I don't use that kind of commands.. I use the command as below.. What mistake did I've done?

#include <stdio.h>
#include <conio.h>

main()
{
int temp;
do
{
temp=getch();
if (temp!=0 && temp !=13)
{
scanf("%s",&temp);
printf("*",temp);
}
}while (temp != 13);

getch();
return(0);
}
Last edited on
Then convert the code to C.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
int temp;

	char c[2] = { ' ', '\0' };
	
	char input[256];
	strcpy(input, "");

	do
	{
		temp=getch();

		c[0] = (char)temp;
		
		if (temp!=0 && temp !=13)
		{
			strcat( input, c );
			printf("*");
		}
	}while (temp != 13);

	getch();
	return(0);


Note: The program will crash if a password larger than 256 characters is entered.
This is my assignment and must be in Borland C++.. That's why I can't convert it to C.. So,could you please reply me with the Borland C++ code.. I really appreciate it..
Last edited on
This is my assignment...


Got any algebra you need done while we're at it? Maybe a report on World History?
Topic archived. No new replies allowed.