Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void userLogin(void)
- {
- int field;
- char usernameFile[20], passwordFile[PASSWORD];
- char username[20], password[PASSWORD];
- /* Enter username and password */
- printf("Please enter a username: ");
- scanf("%s", username);
- fflush(stdin);
- printf("Please enter a password: ");
- scanf("%s",password);
- fflush(stdin);
- infoEncrypt(username);
- infoEncrypt(password);
- /* Opens file in read mode */
- FILE *fp = fopen("password.txt", "r+");
- /* If file cannot be opened/created, it returns an error */
- if (fp==NULL)
- {
- printf("Error");
- getch();
- }
- else
- {
- do
- {
- field = fscanf(fp,"%s %s\n",usernameFile, passwordFile);
- /* Checks to see if username and password is correct */
- if(strcmp(username,usernameFile)==0 && strcmp(password,passwordFile)==0)
- {
- break;
- }
- }while(field == 2);
- printf("%i", field);
- if(field != 2)
- {
- /* If end of file, username and password isn't correct and re-runs */
- system("cls");
- welcome();
- printf("Please enter a correct username and password.\n\n");
- userLogin();
- }
- }
- fclose(fp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement