Answer to Question #314753 in C++ for alanna

Question #314753

Using exec system call list all the files and directories of home then 

store the result in “output1.txt”. Run a second command “grep” and find 

the word “output1.txt” in all the text files of the home also place home 

path in “PATH” environment variable while doing exec for grep. This all 

will be done in one process.


1
Expert's answer
2022-03-20T06:20:13-0400
	if (fs.peek() == EOF)
				{
					cout << "File BD empty" << endl;
					BackEvent(enter3, logos, ftr, colorF, colorW);
					cin >> enter1;
					fs.close();
				}
				else
				{
					while (!fs.eof())
					{

						data[i] = (char*)malloc(sizeof(char) * size);
						fs >> data[i] >> ch;
						if (i > 0)
						{
							ster = ch + data[i];
							data[i] = ster;
						}
						ce = ch;
						cout << data[i] << "\0" << endl;
						i++;
						if (i > 0)
						{
							data.push_back("");
						}
					}


					cin >> loaddata;


					fe.open(data[loaddata]);


					while (fe.peek() == EOF)
					{
						cout << "File " << data[i] << "empty or does not exist!" << endl;
						BackEvent(enter3, logos, ftr, colorF, colorW);
						cin >> enter1;
					}


					while (!fe.eof())
					{
						msg = "";
						getline(fe, msg);


						cout << msg << endl;

}

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