Answer to Question #314547 in C++ for zxc

Question #314547

Write a program that receives one command-line argument: the name



of a text file. Your program will work as follows:



 Start out by creating a child process.



 The child process calls exec to run cat command with command-line argument that



the parent received.




 The parent process calls wait so that it blocks until the child terminates and passes



back its termination status.



 If the child process terminates without error, the parent spawns another child and,



again, calls wait so that it can block until the child terminates.



 The new child calls exec again, but this it runs wc command on the same



the argument that the parent received from the command line.



 Once the parent learns that the child has been terminated, it goes on to terminate also. If



the parent gets to this point, it’s because all has gone well.

1
Expert's answer
2022-03-21T12:40:32-0400
class File
{
public:
	File(string filename)
	{
		try
		{
			cout << "File" << filename << "open" << endl;
		}
		catch (exception exp)
		{
			cout << "Error! " << exp.what() << endl;
		}
	}
private:
	string filename;


};
int main()
{
	string filename;
	cin >> filename;
	File f(filename);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog