My sample code:
Code:
#include <stdio.h>
#include <string.h>
#define name1 "denny"
#define pass1 "123"
int main(int argc, char *argv[])
{ char name[5];
char pass[3];
if(argc != 2)
{ printf("Usage: login Your_Username Your_Password\n");
exit(1);
}
scanf(argv[1],"%s", &name); // to read username argument
scanf(argv[2],"%s", &pass; // to read password argument
if(strcmp(name,name1) == 0 && strcmp(pass,pass1) == 0)
printf("Correct username and password");
else
printf("Wrong username and password");
return 0;
}
Hi I'm a new user of c programming.
My purpose of doing this programming is letting the user to key in their username and password.
The program must be run from console.
It looks like
D:\c>login
Usage:login Your_Username Your_Password
But the problem is, i do not know how to read the username and the password key in by the user. anyone can fix my program?
I'll be very thankful if someone can help me.