Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Expert Solution
arrow_forward
Step 1
Program Description
- Declare two pointers to read from and write to the file input.txt.
- Use the fork function to fork two processes.
- Get the process ID of the function using pid.
- Iterate 200 times and do the following:
- Scan the file and read the integer to N.
- Print N and Process ID.
- Increment N.
- Write N to the file.
Step by stepSolved in 3 steps with 2 images
Knowledge Booster
Similar questions
- Write a Java Program to perform the following operations using FileOutputStream and FileInputStream classes 1) To Count the Number of Vowels and Consonants from a File 2) To Count the Number of Words from a Filearrow_forwardI need help with a C program /* Figure 6.2 */ /* Reads each number from an input file and writes it * rounded to 2 decimal places on a line of an output file. */ #include <stdio.h> int main(void) { FILE *inp; /* pointer to input file */ FILE *outp; /* pointer to ouput file */ double item; int input_status; /* status value returned by fscanf */arrow_forwardA program evaluates binary arithmetic expressions that are read from an input file. All of the operands are integers, and the only operators are +, -, *, and /. In writing the program, the programmer forgot to include a test that checks whether the right-hand operand in a division expression equals zero. When will this oversight be detected by the computer? (A) At compile time (B) While editing the program (C) As soon as the data from the input file is read (D) During evaluation of the expressions (E) When at least one incorrect value for the expressions is outputarrow_forward
- Write a java program that reads a file named input.txt and writes a file that contains the same contents, but is named output.txt. The input file will contain more than one line when tested, so too should the output file and the program must read the file line by line and write the file itselfarrow_forwardWrite a C program that reads real numbers from a data file named "numbers.txt", one-by-one. For each number, the program checks whether the number is positive or negative, and writes only the positive numbers to a text file named "result.txt". The program must use the necessary code to handle File not found/not created errors. Below are examples of the input and output files 3.14 3.14 -25.5 10.25 -22.7 20.0 10.25 20.0 -18.2 тиmbers.txt Results.txt #include int main(void) { //Declare required variables //open required files /*executable statements for: reading a number from input file 2. writing only the positive numbers to output file The above 2 steps are repeated as long as the input file has more numbers */ 1. //close the files printf("\n"); printf("\n"); return 0;arrow_forwardWrite a C program that takes the name of a text file as a input, reads its contents, and then replaces all vowels in the file with the symbol "#". After that it should write back the modified content in the same file and display the message indicating that the file has been successfully modified.arrow_forward
- A process P forks a child C. After the fork(), both parent and child open() the same file for writing using the flag O_WRONLY resulting in descriptor fd. Subsequently P write()'s out a line containing the single character 1 to fd. C write()'s out a line containing the single character 2 to fd. C write()'s out a line containing the single character 3 to fd. P write()'s out a line containing the single character 4 to fd. Assuming that the above actions are ordered chronologically: a )What will be the contents of the file after the above sequence of actions? b ) How can you set things up so that the file captures all of the output?arrow_forwardWrite a program in C++ that reads data from a file. Create dynamic memory according to the data. Now your task is to perform the following task. Row wise Sum Column wise Sum Diagonal wise Sum Example data.txt 4 5 1.6 10.2 33.7 99 20.5 3 44 50 96.1 2 8 9 4 74 50 99 19.1 Output: Sum row wise: 165, 191, 17, 242.1 Sum col wise: 127.6, 120.1, 228.8, 118.1, 20.5 Sum diagonal wise: Not Possible Note: You are restricted to use pointers and your function should be generic as we discussed in class. Avoid memory wastage, memory leakage, dangling pointer. Use regrow or shrink concepts if required.arrow_forwardWrite a C program that reads real numbers from a data file named "numbers.txt", one-by-one. For each number, the program checks whether the number is positive or negative, and writes only the positive numbers to a text file named "result.txt". The program must use the necessary code to handle File not found/not created errors. Below are examples of the input and output files 3.14 3.14 -25.5 10.25 -22.7 20.0 10.25 20.0 -18.2 тиmbers.txt Results.txt #include int main(void) { //Declare required variables //open required files /*executable statements for: reading a number from input file 2. writing only the positive numbers to output file The above 2 steps are repeated as long as the input file has more numbers */ 1. //close the files printf("\n"); printf("\n"); return 0;arrow_forward
- Suppose a library is processing an input file containing the titles of books in order to identify duplicates. Write a program that reads all of the titles from an input file called bookTitles.inp and writes them to an output file called duplicateTitles.out. When complete, the output file should contain all titles that are duplicated in the input file. Note that the duplicate titles should be written once, even though the input file may contain same titles multiple times. If there are not duplicate titles in the input file, the output file should be empty. Create the input file using Notepad or another text editor, with one title per line. Make sure you have a number of duplicates, including some with three or more copies.arrow_forwardWrite a C program that reads real numbers from a data file named "numbers.txt", one-by-one. For each number, the program checks whether the number is positive or negative, and writes only the positive numbers to a text file named "result.txt". The program must use the necessary code to handle File not found/not created errors. Below are examples of the input and output files 3.14 3.14 -25.5 10.25 -22.7 20.0 10.25 20.0 -18.2 тиmbers.txt Results.txt #include int main(void) { //Declare required variables //open required files /*executable statements for: reading a number from input file 2. writing only the positive numbers to output file The above 2 steps are repeated as long as the input file has more numbers */ 1. //close the files printf("\n"); printf("\n"); return 0;arrow_forwardWrite a C/C++ program that accepts 2 command-line arguments: filename of a file of small instructions to interpret number of pages of space to acquire via mmap The contents of the file will consist of sets of these commands:arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY