what I am trying to do is make a program where if the first argument is equal to a randomly generated "password", it will printf that you got through, I keep getting strcmp arg 2 makes pointer without a cast error. Here is the code
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char *argv[]) {
char pass[20], *pas;
int ranmb, len, x;
char range[] = "abcdefghijklmnopqrstuvwxyz1234567890", *rang;
char lenrange[] = { 1, 2, 3, 4, 5 }, *lenrang;
pas = pass;
lenrang = lenrange;
rang = range;
if(argc!=2) {
printf("Enter the password as an argument to enter, \n");
printf("It is also case sensitive.\n");
exit(0);
}
srand((unsigned)time(NULL));
ranmb=rand()%37;
len=rand()%6;
for(x=0;x<*(lenrang+len);x++) {
*pas=*(rang+ranmb);
ranmb=rand()%37;
}
if(strcmp(argv[1],*pas)==0) {
printf("You got through!");
exit(0);
}
else {
printf("Enter the password as an argument to enter, \n");
printf("It is also case sensitive.\n");
exit(0);
}
}