Question
IN UNIX ENVIRONMENT, IN C or C++ PROVIDE SCREENSHOTS OF RUNNING PROGRAM FOR EACH TASK ( i will give a good rating, thanks): Design and
IN UNIX ENVIRONMENT, IN C or C++ PROVIDE SCREENSHOTS OF RUNNING PROGRAM FOR EACH TASK ( 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.
root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin ......................................................... 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
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