Sabtu, 16 Desember 2017

MENYEMBUNYIKAN KARAKTER

Berikut adalah program untuk menyembunyikan karakter di Dev C++

source code:

#include<iostream>
#include<conio.h>
#include <windows.h>
using namespace std;
void gotoxy(int x, int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
int  main()
{
cout<<"Enter password: \n";
restart:int x[100],x1[100],i,j=0,k=0,l;
for(i=0;i<=100;i++)
{
pass:l=getch();
if(((l>=48)&&(l<=126))||(l==8)||(l==13))
x[i]=l;
else goto pass;
if(x[i]==13)
break;
else if(x[i]==8)
{
gotoxy(1,2);
for(i=0;i<100;i++)
x[i]='\0';
goto restart;
}
else
{
cout<<"*";
k++;
}
}
cout<<"\nRe enter password: \n";
for(i=0;i<=k;i++)
{
x1[i]=getche();
if(x1[i]==13)break;
}
for(i=0;i<=k;i++)
if(x[i]!=x1[i])
j++;
if(j==0)
cout<<"\nPasswords match!!\n";
else cout<<"\nPasswords do not match!!\n";
getch();
}


Output:

Tidak ada komentar:

Posting Komentar