បង្កើត Password ក្នុង C++
#include<iostream.h>
#include<conio.h>
void main(){
textbackground(0);
clrscr();
gotoxy(25,20);
textcolor(4);
cprintf("nisit-pdachsongkha.blogspot.com");
int a,c=0,t=0;
int max=5; // កន្លែងនេះសម្រាប់ដាក់ចំនួន Password បើ passf មាន 10
char ch,pass[20]; // ខ្ទង់ ត្រូវដាក់ max =10;
char passf[20]={'1','2','3','4','5'}; // កន្លែងនេះសម្រាប់ដាក់ Password login
window(20,5,60,15);
textbackground(7);
clrscr();
gotoxy(18,1);
textcolor(5);
cprintf("Password");
window(21,6,59,14);
textbackground(1);
clrscr();
gotoxy(2,5);
textcolor(2);
cprintf("Password Login : ");
window(40,10,58,10);
textbackground(7);
textcolor(0);
clrscr();
gotoxy(2,1);
do{
ch=getch();
if(ch!=13&&ch!=8&&c<=16) //13 key enter ,8 key backspace
{
cout<<"*";
pass[c++]=ch;
}
if(ch==8&&c>0)
{
cout<<"\b \b"; // \b back cursor
pass[--c]='\0'; // '\0' = null remove data from RAM
}
}while(ch!=13||c==0);
for(int i=0;i<max;i++){
if(pass[i]==passf[i])
t++;
}
window(1,1,80,25); // full window
textbackground(0);
clrscr();
gotoxy(35,8);
textcolor(4);
if(t==max)
cprintf("Password Right");
else
cprintf("Password wrong");
getch();
}