Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C, Complete populateUsers, which reads the file credential file line-by-line, gets the firstname, lastname, username, password and admin from each line to populate users

In C, Complete populateUsers, which reads the file credential file line-by-line, gets the firstname, lastname, username, password and admin from each line to populate users array2 .

#include #include #include #include < unistd.h> struct user { char username [50]; char password [256]; char firstname [50]; char lastname [50]; int admin ; };

void populateUsers ( void * users ) { // Your code goes here }

int main ( void ) { int user_count = 0; struct user * users = createUsers (& user_count ); if ( users == NULL ) { return EXIT_FAILURE ; }

populateUsers ( users );

printf (" Enter admin password to add new users :"); char entered_admin_password [50]; scanf ("% s " , entered_admin_password );

if ( checkAdminPassword ( entered_admin_password , users , user_count )) { struct user new_user ; printf (" Enter username :"); scanf ("% s " , new_user . username ); printf (" Enter first name :"); scanf ("% s " , new_user . firstname ); printf (" Enter last name :"); scanf ("% s " , new_user . lastname ); printf (" Enter password :"); scanf ("% s " , new_user . password ); printf (" Enter admin level :"); scanf ("% d " , &( new_user . admin )); users = addUser ( users , & user_count , new_user . username , new_user . password , new_user . firstname , new_user . lastname , new_user . admin ); if ( users == NULL ) { return EXIT_FAILURE ; } } saveUsers ( users , user_count ); free ( users ); return EXIT_SUCCESS ; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Find dy/dx if x = te, y = 2t2 +1

Answered: 1 week ago