Hello everyone i have to do simple login program in C, i have a problem to save username, full name and password because i need to choose '1' for sign up and '2' for sign in but always when i exit the console and try to read my file everything disappears.
#include <stdio.h>
int main() {
FILE *f = fopen("users.txt", "w+");
if (f == NULL) {
printf("N/A");
exit(1);
}
int choose,
username[15],
fullName[20],
password[15],
// confirmPassword[15];
printf("Welcome!\n");
printf(" 1: Sign up\n 2: Sign in\n");
printf("--------------------------------\n");
scanf("%d", &choose);
if(choose==1) {
printf("Username: ");
scanf("%s", &username);
printf("Full name: ");
scanf("%s", &fullName); /// BECAUSE OF SPACE IT COUNTS LIKE A PASSWORD
printf("Password: ");
scanf("%s", &password);
fprintf(f, "%s\n%s\n%s", username, fullName, password);
}
if(choose==2) {
char c;
printf("Username: ");
while( c != EOF) {
c = fgetc(f);
printf("%c",c);
}
}
fclose(f);
return 0;
}
I have to deal with HASH too but i will try that on my own. And help about /// comment !