Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need this in c programming PLEASE DO ALL PARTS THIS FROM ONE SINGLE ASSIGNMENT assignment is given and also code is given you just

I need this in c programming

PLEASE DO ALL PARTS THIS FROM ONE SINGLE ASSIGNMENT

assignment is given and also code is given you just have to

code the lines where it says TODO here

please edit the code that i have given and please send me screenshot of the output as well

please only edit this below code shown. any other form will not work

image text in transcribed

image text in transcribed

image text in transcribed

#include #include // TO DO

int main(int argc, char** argv) { assert(argc >= 2); char* cmd = "./greeter"; char* const parmList[] = {cmd, argv[1], NULL};

// TO DO

printf("Child process (pid: %d) exited with status %d. ", ?, ?/* TO DO */); printf("Parent Process (pid: %d) exiting now. ", ?/* TO DO */); return 0; }

image text in transcribed

// TO DO

int main(int argc, char** argv) { // TO DO

return 0; }

image text in transcribed

#include

int main(int argc, char** argv) { if (argc >= 2) printf("Hello %s! ", argv[1]); return 3; }

Welcome to Lab 5! Th also learn how to duplicate processes and use several system call functions. Please check on Mimir for the due date of this lab assignment e purpose of this lab is to learn reading from and writing to files. In this lab, we will Part 1: Filter Lines. You will modify the program filterlines.c that reads from a text file named input.txt. In the text file, some lines will not have any capital letters. Your task will be to find the lines that do not have any capital letters and write them into a new output text file. The name of the output text file will be passed from the command line. However, if the command line does not pass any name as an argument, your code should use the name al1small.txt. You must use C library functions declared in stdio.h, for example, fopen(), fgets ), fputs), and fclose) to operate on the file. You can assume that no line will have more than 256 characters (including the newline character). You can use standard C string library functions for this assignment Include all the necessary header files so that the code does not give any warning at compile time. You are encouraged to use the man pages for this. Sample input and output files are given below input.txt 1 Lorem ipsum dolor sit amet, consectetur1 adipiscing elit, sed do eiusmod tempor 2 adipiscing elit, sed do eiusmod tempor 3 incididunt ut labore et dolore 4 aliqua. Ut enim ad minim veniam, quis4 nisi ut aliquip ex ea commodo consequat. 5 nostrud exercitation ullamco laboris 6 nisi ut aliquip ex ea commodo consequat. 6 sint occaecat cupidatat non proident, 7Duis aute irure dolor in reprehenderit 8 in voluptate velit esse cillum dolore 9eu fugiat nulla pariatur. Excepteur 10 sint occaecat cupidatat non proident 11 sunt in culpa qui officia deserunt 12 mollit anim id est laborum all small.txt 2 incididunt ut labore et dolore magna 3 5 7 nostrud exercitation ullamco laboris in voluptate velit esse cillum dolore sunt in culpa qui officia deserunt magna 8 mollit anim id est laborum. Part 2: Execute Another Program. In this part of the assignment, you will modify a small C program exec another.c that will execute another program. For the purpose of this assignment, we have written a very small and polite C program named greeter.c that takes a string from the command line, and greets by simply saying hello. For example, if you run the greeter program with argument World (./greeter World), it will print "Hello World!" on the screen. The source code for the greeter program is attached in the started folder. Do not modify this progranm Note that, at a successful execution it exits with status 3 (aka returns 3) Step 1. In your program, you will use forkO to create a child process. Inside the child process, using execvp) function, you will execute the greeter program. Take a string from the command line to pass to the greeter program. Step 2. The parent process waits for the child process to exit and then prints out the process id and exit status of the child process using the following format string: "child process (pid: %d) exited with status %d.' " Step 3. Finally, the parent process prints out its own process id using the following format and exits. "Parent Process (pid: %d) exiting now . " Include all the necessary header files so that the code does not give any warning at compile time. You are After successful execution, your output will be somewhat like this. /exec_another World Hello World! Child process (pid: 1123) exited with status 3. Parent Process (pid: 1122) exiting now. G exec_another.cx filter_lines.c greeter.c #include 2 #include 3 I/ TO DO 4 5 int main(int argc, char** argv) 7 assert (argc2); 8 9 char* cmd./greeter"; char* const parmLi st[] = {cmd , argv [1], NULL); / TO DO printf("child process (pid: %d) exited with status %d.in", ?, ?/> printf("Parent Process (pid: %d) exiting now. ", ?/* TO DO */); return ; 10 12 TO DO 16 17 C exec_another.c fhlter_lines.c x // TO DO 2 3 int main(int argc, char** argv) 4 5 6 7 8 // TO Do return ; C exec_another.c C filter_lines.cgreeter.c x Hinclude 2 3 int main(int argc, char** argv) 4 5 6 if (argc >= 2) printf("Hello %s ! ", argv [1]); return 3 8

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

8. Do the organizations fringe benefits reflect diversity?

Answered: 1 week ago

Question

7. Do the organizations social activities reflect diversity?

Answered: 1 week ago