Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Questions are referring to commands in a Linux Virtual Machine terminal. Please answer all three parts, a, b, and c! 1) Suppose that the following

Questions are referring to commands in a Linux Virtual Machine terminal. Please answer all three parts, a, b, and c!

1) Suppose that the following C source code testprog.c is compiled into an executable file testprog.

testprog.c code is below:

_____________________________________________

int main(int argc, char **argv) { char **p = &argv[2]; printf("%d %c %c ", argc, *(*p + 3), **(p + 3)); return 0; }

___________________________________________

a. If you run testprog with the arguments below, it should output 7 g n, as shown: $ ./testprog This program has many nasty bugs 7 g n Explain in full detail why it is printing the three letters 7, g, and n.

b. Next, you will get a different output (an error) if you run the same program as follows: $ ./testprog Test Explain your program output in this case, and why it differs from the previous case.

c. Finally, still another output is seen if the program is run without any arguments: $ ./testprog If your error from the previous part went away, can you explain why?

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

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

0764549634, 9780764549632

More Books

Students also viewed these Databases questions