1. Create a C++ program that takes a command line argument value (userid) and pa
ID: 3666836 • Letter: 1
Question
1. Create a C++ program that takes a command line argument value (userid) and passes this argument to a shell script. HINT: system()
2. As in the previous assignment, modify your makele to include a rule that creates a backup of the source les, makele, and readme in an archive directory in your home directory structure. Submit an uncompressed tar le named $USER.ndname.tar with your modied source code. (ie yourUserid.ndname.tar) Be sure to document your code in a README le.
• In order to obtain credit for your project your submission must react properly to the following commands:
$ tar xvf $USER.findname.tar $ make $ ./findName someuserid $
3. Your program will be graded based on it’s ability to execute the above commands and return one of 3 allowable outputs:
• rst lastname, or • some error message based on an incorrect number of command line arguments, or • the message stating that the user is not in CSCE215 this semester
Explanation / Answer
Can help you with bit 1
1)
#include <string>
#include <cstdlib>
int main(int argc, char* argv[])
{
std::string command = "./findName.sh";
if(argc == 2)
std::system((command + " " + argv[1]).c_str());
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.