Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. FILE *fp;
  5. char username[30];
  6. char password[30];
  7. char password2[30];
  8.  
  9. void enterpw() {
  10.  
  11.         printf ("\nPassword: ");
  12.         fgets (password, sizeof(password), stdin);
  13.  
  14.         printf ("Confirm password: ");
  15.         fgets (password2, sizeof(password2), stdin);
  16.  
  17.         while (strcmp(password, password2)) {
  18.                 enterpw();
  19.         }
  20.  
  21. }
  22.  
  23. int main() {
  24.  
  25.         printf ("\nPlease enter your username: ");
  26.         fgets (username, sizeof(username), stdin);
  27.  
  28.         enterpw();
  29.  
  30.         fp = fopen ("user.dat", "a");
  31.         fprintf (fp, "%s%s\n", username, password);
  32.         fclose (fp);
  33.  
  34.         printf("\n");
  35.         return 0;
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement