Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started