C command line password

Posted by Jack Jacobsen on Stack Overflow See other posts from Stack Overflow or by Jack Jacobsen
Published on 2011-01-06T01:09:08Z Indexed on 2011/01/06 1:53 UTC
Read the original article Hit count: 498

Filed under:
|

So I'm trying to create a C program where you must input the password on the command line, like ./login password1 And if the password is password1, it'll say something. If not, it prints another message. This is the code I have now:

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  if (argc < 2) {
    printf("usage: %s <password>\n", argv[0]);
  }
  char pass = "password";
  if (argc == pass) {
    printf("Right\n");
  } else {
    printf("Wrong\n");
  }
}

But it wont work.

© Stack Overflow or respective owner

Related posts about c

    Related posts about cli