0
if(strcmp(un,this->username)==0 && strcmp(pw,this->password)==0)

Could anyone of you please instruct me the significance of "this" function? Also, what could be a possible alternative of it?

  • I think this question needs. a little more contexts on what other variables are available to this if statement and if the compiler needs the programmer to clarify if there is more that one choice for `username` and `password` – Kavfixnel Dec 16 '20 at 21:43

1 Answers1

1

It's only necessary if you need to distinguish the member variable username from one that's local to the function that contains your if statement.

The same applies to password.

If neither apply then you can write

if (!strcmp(un, username) && !strcmp(pw, password))

By the way, using a contiguous character array to store a password is not particularly secure. You wouldn't see code like this in a professional context.

Bathsheba
  • 231,907
  • 34
  • 361
  • 483