STRING COMPARISON PROGRAM IN CPP - PASSWORD EXAMPLE
//Example of string comparision function
//Password program.
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
{
char pwd1[20], pwd2[20];
clrscr();
cout<<"Enter string to set as password: ";
gets(pwd1);
cout<<"....Password set\n";
cout<<"Enter password again to check: ";
gets(pwd2);
if(strcmp(pwd1,pwd2)==0)
cout<<"\nPassword matched...";
else
cout<<"\nPassword mismatched...";
getch();
}
//Password program.
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
{
char pwd1[20], pwd2[20];
clrscr();
cout<<"Enter string to set as password: ";
gets(pwd1);
cout<<"....Password set\n";
cout<<"Enter password again to check: ";
gets(pwd2);
if(strcmp(pwd1,pwd2)==0)
cout<<"\nPassword matched...";
else
cout<<"\nPassword mismatched...";
getch();
}
No comments
Post your comments