Question: Question I: ------------ Using system calls read() and write(), define two functions, readInt(), and printInt() to read/write integers from keyboard. When the user enters a
Question I: ------------ Using system calls read() and write(), define two functions, readInt(), and printInt() to read/write integers from keyboard. When the user enters a nonvalid integer, readInt() shoudld print an error message, using write(), and exit with a code of 1. Use the program below in your tests. #include#include #include int readInt(); void printInt(int); int main(int argc, char *argv[]){ int intNum1, intNum2, intSum; char message1[20]="Enter an integer> "; char message2[40]="the sum of the two numbers is: "; write(STDOUT_FILENO, message1, 18); intNum1 = readInt(); write(STDOUT_FILENO, message1, 18); intNum2 = readInt(); intSum = intNum1+intNum2; write(STDOUT_FILENO, message2, 32); printInt(intSum); exit(0); } int readInt(){ complete the code here } int printInt(int val){ complete the code here } Question 2: Write a C program that creates two children using the fork(). Each process should print its own PID and its PPID. Furthermore, the parent process should print the PIDs of its two child processes. Important: the child processes should not create any new children.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
