Question
#include #include #define MAX_NUMS 500 #define PASSWORDS_MISSING 1 #define STRING_SIZE 1024 int main() { int ints[MAX_NUMS]; char debug = 0; double sum; double doubles[MAX_NUMS]; int
#include
#define MAX_NUMS 500 #define PASSWORDS_MISSING 1 #define STRING_SIZE 1024
int main() { int ints[MAX_NUMS]; char debug = 0; double sum; double doubles[MAX_NUMS]; int selection, icount = 0,dcount = 0; char user[STRING_SIZE], password[STRING_SIZE], curpass[STRING_SIZE], curuser[STRING_SIZE]; user[0] = 0; password[0] = 0; strcpy(user, "None Entered"); FILE *login; char loggedIn; while(1) { loggedIn = 0; while(1) { printf("1) Log in 2) Exit "); scanf("%d", &selection); if (selection == 1) { printf(" User: "); scanf("%s", user); printf("Password: "); scanf("%s", password); login = fopen("passwords", "r"); if (login == 0) { printf("Could not open passwords file "); return(PASSWORDS_MISSING); } while(fscanf(login, "%s%s", curuser, curpass) != EOF) { if (strcmp(curuser, user) == 0 && strcmp(curpass, password) == 0) { loggedIn = 1; } } if (loggedIn == 0) { printf("Login failed "); } else { printf("Logging in "); break; } for (selection = 0; selection < STRING_SIZE; selection++) { password[selection] = curpass[selection] = 0; } fclose(login); } else if (selection == 2) { printf("Exiting now "); return(0); } } while(1) { printf("Press 1 for Author name and ID Press 2 to enter floating point value Press 3 to enter integer value Press 4 to clear entered values Press 5 to print all values Press 6 to save data Press 7 to load data Press 0 to log out "); scanf("%d", &selection); if (selection == 1) { printf("Bravo 1234567 "); } else if (selection == 0) { dcount = icount = 0; break; } else if (selection == 3) { if (icount == MAX_NUMS) { printf("You have reached the max, you must clear data before storing more. "); continue; } printf("Enter value "); scanf("%d", &ints[icount++]); } else if (selection == 2) { if (dcount == MAX_NUMS) { printf("You have reached the max, you must clear data before storing more. "); continue; } printf("Enter value "); scanf("%lf", &doubles[dcount++]); } else if (selection == 4) { icount = dcount = 0; } else if (selection == 5) { sum = 0; printf("FP Value: "); for (selection = 0; selection < dcount; selection++) { sum += doubles[selection]; printf("%lf ", doubles[selection]); } printf(" Int Value: "); for (selection = 0; selection < icount; selection++) { sum += ints[selection]; printf("%d ", ints[selection]); } printf(" Sum Value: %lf ", sum); } else if (selection == 6) { } else if (selection == 7) { } else { printf("Invalid selection "); continue; } } } return(0); }
Option 6 Must ask the user to enter a file name and then your program should allow option 7 to work, how you go about doing this is up to you,
Option 7 Must ask the user to enter a file name, then it should load the data stored in that save file if the save file was generated by the currently logged in user, if the user is different then do not load the data
also implement a working log file.Record each time the program starts or exits. Each time a user attempts to log in it must record if the attempt succeeded or failed. It must also record each time a file was saved/loaded, when this is recorded give the current user name as well as the name of the file
You will need to create a word file "passwords" and should have alpha beta in to the word file saved.
password is: alpha beta
comment with any questions..
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started