Question: Section1 Answer the following questions Using the file input.c Code: #include #include string.h int main(int argc, char* argv[]) { int i, j, k; int x[1000];
Section1
Answer the following questions
Using the file input.c
Code:
#include
int main(int argc, char* argv[]) { int i, j, k; int x[1000];
for(i = 0; i < 10000; ++i){ x[i] = i; }
printf("Enter integer in 0..9999: "); scanf("%d", k);
tester(x, k); }
int tester(int* c, int k) { printf("x[%d] = %d ", k, c[k]); }
1) Creat a Makefile to compile the program
a) Are there any warnings?
b) What is the difference if we add the argument "-Wall" to the compilation ? Modify the Makefile to include the "-Wall" argument.
2) Execute the program. Is there any error ?
3)Open the program with the gdb. What do you have to do first ?
a) Run the program inside gdb. What do you have to do first ?
b) Insert a breakpoint to the main function and run the program again.
c) Choose which command helps you find any mistakes (next, step, continue)
4 Identify the exact lines of the errors and the messages that the gdb prints. Find and correct these errors
Section 2
Write a program that:
1) Asks form the user an integer number N (N>10)
2) Creates N processes that:
a) Each process prints its own PID
b) Each process prints the current time (Tip: check the C date and time funcations)
3) The parent process should print its own ID
4) Run the program 5 times and keep the output. Is it different in some cases?
Explain why this happens
5) Are the PIDs of the processes the same each time you execute the program ?
6) What is the maximum limit to the number of processes possible in a Unix system ? Verify with your program
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
