Help with this program..I only get the true valu of the condition.

I compared two strings but i only get the 'true' condition..help please..TIA!
[code]
#include <iostream>
#include<conio.h>
using namespace std;
main()
{
char name[30],pass[10],conpass[10];
int i=0,d=0;
cout<<"Enter Account Name: ";
cin>>name;
cout<<"Enter Password: ";
pass[0]=_getch();
while(pass[i] =13)
{
i++;
cout<<"*";
pass[i]=_getch();
}
cout<<"\nConfirm Password:";
conpass[0]=_getch();
while(conpass[d]!=13)
{
d++;
cout<<"*";
conpass[d]=_getch();
}
if (strcmp(pass,conpass)!=0)
{
cout<<"\nRegistration complete!";
}
else
{
cout<<"\nTry again!";
}
system ("pause>0");




}
Last edited on
i always get a true value if i use ==, while the strcmp doesnt work..
while(pass[i] =13)
This makes no sense. What are you trying to do with this line of code?
am sorry @Moschops that was supposed to be pass[i]!=13
Last edited on
if (strcmp(pw,conpass)!=0)

I see you're trying to compare conpass and pw. This is unfortunate, as pw doesn't exist. You can only compare variables that exist.
sorry my bad..i chaged it now..
it alway says
[Error]'strcmp' was not declared in this scope.
You forgot to include the <cstring> header that defines this function. So the function isn't actually declared in your code and the compiler cannot find it.
it worked but it only returns the 'true' value..
strcmp returns zero when the two strings are the same.
Topic archived. No new replies allowed.