0

I'm having a little problem regarding this log-in program.

#include<stdio>
#include<conio>
#define p printf
#define s scanf

main()
{

    char pass[20];
    char user[20];

    clrscr();

    p("\nEnter your username: ");
    s("%s", user);

    p("\n\nEnter your password: ");
    s("%s",  pass);

    if(user=="abel" && pass=="pass")
        p("\nW E L C O M  E !!");
    else
        p("\nINVALID INFORMATION!!");

  getch();
  return 0;
}

Even if I enter the correct username (user) and password(pass), it would still goes directly to the else statement. Logic error, or am I missing something.

Thanks!!

2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by WaltP
1

if(user=="abel" && pass=="pass")

Look up how to compare strings again. You need to use strcmp()

And remove your 2 #define's. They make the code harder to understand, not easier.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.