Question: /* Change this program so that it takes a command-line argument that it will interpret as a username, and it will print out the information

/*

Change this program so that it takes a command-line argument that it will

interpret as a username, and it will print out the information about that

user. It should print the username, name, email address, and home directory.

Example run.

./user_info.o cs50000

user: cs50000

name: Jeff Kinne

email: jkinne@indstate.edu

home directory: /u1/class/cs50000

*/

#include

#include

#include

int main(int argc, char *argv[]) {

FILE *passwd = fopen("/etc/passwd", "r");

char * line = NULL;

size_t max_length = 0;

ssize_t ret_val = 0;

char line_copy[1000];

while ((ret_val = getline(&line, &max_length, passwd)) > 0) {

strncpy(line_copy, line, 999);

char *username = strtok(line_copy, ":");

if (strcmp(username,"jkinne") == 0)

printf(line);

}

fclose(passwd); passwd = NULL;

return 0;

}

**CAN YOU HELP ME MODIFY THE CODE**

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!