Hi everyone,

I'm building a login function. I have two files - one with the user login and other with the password (needs to be this way).

Code:
int loginn(){
	
	FILE* fileusers;
	FILE* filepassword;
	char auxusers[MAX];
	char auxpassword[MAX];
	char login[MAX];
	char password[MAX];
	char option;
	fileusers = fopen("../../config/users", "r");
	filepassword = fopen("../../config/pass", "r");
	int access = 0;

	printf("Login:\n");
	fgets(login,sizeof(login),stdin);
	
	printf("Password:\n");
	fgets(password,sizeof(password),stdin);
	
	if( login[strlen(login)-1] == '\n')
		login[strlen(login)-1] = 0;
	
	if( password[strlen(password)-1] == '\n')
		password[strlen(password)-1] = 0;
	
	if(fileusers && filepassword){
		while(((auxusers[MAX] = fgetc(fileusers)) != EOF) || (auxpassword[MAX] = fgetc(filepassword)) != EOF){
			if((strcmp(auxusers, login) == 0) && (strcmp(auxpassword, password) == 0)){
				printf("-- Login OK --\n");
				access = 2;
			}else{
				printf("-- Login is wrong --\n");
				printf("-- To register, press < R > or press < L > to try again. --\n");
				
				
				scanf("%c", &option);
				switch(option)
				{
					case 'R':	printf("-- You need to be a super user to create a new user.-- \n");
								loginSuperUser();
								if(access == 1)
									createUser();
								break;
						
					case 'L':	printf("Login2:\n");
								fgets(login, sizeof(login), stdin);
						
								printf("Password2:\n");
								fgets(password, sizeof(password), stdin);
								break;
					default: "ups\n";
				}
			}
		}
	}else{
		perror("Error\n");
		exit(0);
	}
}
The compilation doesn't show any warning or error, however, even when I insert the right user and password, the program goes directly to the "login is wrong" part.

Do you guys have any idea of what could be wrong?


Thanks in advance!