Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN UNIX ENVIRONMENT, IN C or C++ MAKE SURE CODE WORKS, OTHER CODE ONLINE DO NOT WORK ( i will give a good rating, thanks):

IN UNIX ENVIRONMENT, IN C or C++ MAKE SURE CODE WORKS, OTHER CODE ONLINE DO NOT WORK ( i will give a good rating, thanks):

Design and implement C++ program (a3part2.cpp) with the password file (/etc/passwd) to do the following tasks.

......................................................... Task1. .......................................................... Design and implement a class (passwd) which contains member variables for each field of the password file (/etc/passwd). You will have an array (passwdArray) of which each element is an instance-object of passwd class (from each record of the passwd file). Reading the password file (/etc/passwd), each record will be instantiated as an object of the passwd class and set to be an element of an array. Output each record (object) in the array (passwdArray) to a file (a3p2task1.txt).

Object 1 user: root uid: 0 gid: 0 gecos: root home: /root shell: /bin/bash

Object 2 ........................................... Task2 ........................................... Output each passwd object in the passwdArray, into a binary file (a3p2task2.bin).

Then your program is to read this binary file (a3p2task2.bin), reading each passwd object from the file, into another password array (passwdArray2). Then output each object as you have done in Task1 to a file (a3p2task2.txt). ............................... Task #3 ............................... Create a Map object (passwdMap) where its key is uid and its value is gid. Populate map entry from each object in passwdArray. Print each entry in passwdMap in ascending order by the key value.

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

Step: 3

blur-text-image

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

You have

Answered: 1 week ago