1 Replies - 8894 Views - Last Post: 20 January 2009 - 07:05 PM Rate Topic: -----

#1 alleroid16   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 06-December 08

password make it asterisk

Posted 20 January 2009 - 05:48 PM

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<dos.h>
#include<stdlib.h>

char *ptr;
char gio[150];
int x;
char password[150];

void main()
{
	  clrscr();
	  cout<<"ENTER PASSWORD:  ";
	  gets(password);
	  x=strcmp(password, "algernon");
		if(x==0)
		  cout<<"HELLO";
		else
		exit(1);

	 clrscr();
	
	  for(int a=1;a<=80;a++)
	{
	gotoxy(a,1);cout<<"\xDB";
	gotoxy(a,24);cout<<"\xDB";
	delay(30);
	gotoxy(37,13);cout<<"LOADING!!!";
	}

	clrscr();
	gotoxy(34,10);cout<<"ENTER SENTENCE:  ";
	gotoxy(34,12);gets(gio);
	ptr=strstr(gio, "a");
	strncpy(ptr,"A",1);

	while(ptr!=NULL)
{
	ptr=strstr(gio,"a");
	strncpy(ptr,"A",1);
}

	ptr=strstr(gio, "e");
	strncpy(ptr,"E",1);

	while(ptr!=NULL)
{
	ptr=strstr(gio,"e");
	strncpy(ptr,"E",1);
}

	ptr=strstr(gio, "i");
	strncpy(ptr,"I",1);

	while(ptr!=NULL)
{
	ptr=strstr(gio,"i");
	strncpy(ptr,"I",1);
}

	ptr=strstr(gio, "o");
	strncpy(ptr,"O",1);

	while(ptr!=NULL)
{
	ptr=strstr(gio,"o");
	strncpy(ptr,"O",1);
}

	ptr=strstr(gio, "u");
	strncpy(ptr,"U",1);

	while(ptr!=NULL)
{
	ptr=strstr(gio,"u");
	strncpy(ptr,"U",1);
}

gotoxy(34,14);cout<<gio<<endl;

getch();
}


here's my code. the only problem there is, i need to make it asterisk whenever i am going to put my password. how could i do that? like when we are loging in here, when we are putting our password it appears like a bullet not letters.

thanks in advance!

Is This A Good Question/Topic? 0
  • +

Replies To: password make it asterisk

#2 Hyper   User is offline

  • Banned

Reputation: 108
  • View blog
  • Posts: 2,129
  • Joined: 15-October 08

Re: password make it asterisk

Posted 20 January 2009 - 07:05 PM

A method you could use is something similar to this (it's very crude):

#include <iostream>
using namespace std;

int main() {

    char Password[5] = {'\0'};

    for (int x = 0; x != sizeof(Password); x++) {
    cout << "Input password (5 characters): ";
    cin >> Password[x];
    cout << "\b*";
    }

    cout << "Press any key to exit";
    _flushall();
    cin.get();
    return 0;
}

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1