Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C Programming (Needs to be done with C Programming) Reference for functions in C: http://www.cplusplus.com/reference/clibrary/ Coding Assignment (100 points in total) Please copy the supplied
C Programming (Needs to be done with C Programming)
Coding Assignment (100 points in total) Please copy the supplied code and test inputs by copy the following folder to your working directory. You should see two C program, and 6 input cases for the 3 tasks cp /home/rwang67/public/lab4/ Task 1(30 points) Compile and run the program analyze,c. Modify the program to replace the loop containing repeated getchar() calls with a single call to fgets(). Here is a quick tip on its usage fgets(text, MAX, stdin); fgets stands for "get string from file", and it stores the string read into text, reading up to a maximum number of MAX characters, from the file specified in the third argument, which in our case is the "standard input" or stdin (meaning keyboard, or a file if input is redirected using Once you make this change, however, you will no longer have the length of the string in length so you will have to use the C library function strlen() to compute the length of the string Note that the string read using fgets has a newline character at the end, and strlen includes this newline character in the length of the string, which is not what we want. So, adjust the string length accordingly Note that while there are several others ways to accomplish this exercise, you must do exactly as explained above, in particular: (i) use fgets() to read the line of input; and (ii) use strlen()to compute the length of the input line Call your program ex1.c. Compile it and run it on a few inputs of your choice. Also, run it on the sample inputs provided and save the output files. Reference for functions in C: http://www.cplusplus.com/reference/clibra Reference for functions in C:
http://www.cplusplus.com/reference/clibrary/
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