Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Advances In Spatial And Temporal Databases 11th International Symposium Sstd 2009 Aalborg Denmark July 8 10 2009 Proceedings Lncs 5644

Authors: Nikos Mamoulis ,Thomas Seidl ,Kristian Torp ,Ira Assent

2009th Edition

3642029817, 978-3642029813

More Books

Students also viewed these Databases questions