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!!

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.