I wrote this small program that enters a password from a user and displays '*' instead of the letters so I could add this into my project.
I compiled it through Dev C++ using Windows 7 and I am getting errors, please help me out.
The program :-
#include<iostream.h>
#include<conio.h>
#include<string.h>
char enterPass();
void passFunc();
char enterPass()
{
char numPass[11];
char ch;
int i=0;
while((ch!='\r')||(ch!='\n')&&(i!=10))
{
cin>>ch;
cout<<'*';
numPass[i]=ch;
i++;
}
return numPass[11];
}
void passFunc()
{
char pass[11];
cout<<"Enter password :- ";
pass=enterPass();
if(strcmp(pass,"myworld")==0)
{
cout<<"Correct Password";
getch();
}
else
{
cout<<"Wrong Password";
exit(0);
}
}
int main()
{
passFunc();
getch();
return 0;
}
Errors I am getting are :-
24 C:\Users\Dhruv\Desktop\pass.cpp incompatible types in assignment of `char' to `char[15]'
24 C:\Users\Dhruv\Desktop\pass.cpp At global scope: