Question: Run the program below with 4 command line arguments of your own choosing, at least one of which is a flag and one of which

Run the program below with 4 command line arguments of your own choosing, at least one of which is a flag and one of which is a non-flag argument.

The program displays argv addresses a. Record the command line that you used. b. From the program output, report the base address (the starting address) of argv and range of addresses used store the command line.

A. Record the command line that you used.

B. From the program output, report the base address (the starting address) of argv and range of addresses used store the command line.

//The code given

/* Purpose: shows the arguments on the cmd line ie: showArgs one two three *.c */ #include #include #include int main(int argc, char * argv[],char * envp[]) { fprintf(stdout,"My name is %s. I'm process #%d." "I have %d cmd line args ", argv[0],getpid(),argc); //Showing the command line args for(int i=0;argv[i];i++) fprintf(stdout,"%p. %s [%p] ", &argv[i], argv[i], argv[i]); fprintf(stdout,"Look at what's at location argv[argc]: location: %p value: %p ", &argv[argc], argv[argc]); system("bash"); //create a subshell to look at /proc/pid/cmdline fprintf(stdout,"We're back "); fprintf(stdout," ... Just in time to leave!!! "); return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!