Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <ctype.h>
- #include <math.h>
- #include <string.h>
- int main()
- {
- FILE * user;
- char choice;
- char * username;
- char * password1;
- char * password2;
- int i;
- int j;
- bool digit, upper, lower;
- username = (char *) malloc( 25 * sizeof(int) );
- password1 = (char *) malloc( 25 * sizeof(int) );
- password2 = (char *) malloc( 25 * sizeof(int) );
- printf("Do you have an account? <y/n>\n");
- scanf(" %c", &choice);
- if(choice == 'n'){
- puts("\nWell its time to make one ...\n");
- puts("Enter your username dude :");
- scanf(" %s",username);
- strcat(username, ".txt");
- while(1){
- while(1){
- puts("Enter your password and try to make it strong (use upper case and lower case letters and numbers) ");
- scanf(" %s",password1);
- for(i = 0; i < strlen(password1); i++){
- if( isdigit(password1[i]) ){
- digit = true;
- }else if( isalpha(password1[i]) ){
- if( isupper(password1[i]) ){
- upper = true;
- }else{
- lower = true;
- }
- }
- }
- if(digit==true && upper==true && lower==true){
- break;
- }
- printf("Are you deaf? I said a strong password!!!\n");
- }
- puts("Reenter the pasword :");
- scanf(" %s", password2);
- j=0;
- for(i=0; i<strlen(password1); i++){
- if(password1[i] == password2[i]){
- j++;
- }
- }
- if(strlen(password1) == strlen(password2) && i == j){
- break;
- }
- puts("That isn't your password...");
- }
- user = fopen(username, "w");;
- fprintf(user, "%s", password1);
- }else{
- while(1){
- puts("Then enter your username : ");
- scanf(" %s", username);
- strcat(username, ".txt");
- user = fopen(username, "r");
- while(!feof(user)){
- fgets(password2, 25, user);
- }
- puts("Enter your password : ");
- scanf(" %s", password1);
- j=0;
- for(i=0; i<strlen(password1); i++){
- if(password1[i] == password2[i]){
- j++;
- }
- }
- if(strlen(password1) == strlen(password2) && i == j){
- puts("Well your in ... What do you want to do, because there is nothing to do... :(");
- }else{
- puts("It seems that you don't have an account, or maybe you entered your username/password incorrectly.");
- puts("Please try again.");
- }
- }
- }
- fclose(user);
- free(username);
- free(password1);
- free(password2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement