Question
Please be accurate with your work. Please fix my (C) program. I will post the directions, example of the output, and my program with the
Please be accurate with your work.
Please fix my (C) program. I will post the directions, example of the output, and my program with the current grade(3/6) of my program. My program is almost complete, but I need someone to modify it so it dosn't use gets(), I need it to use fgets().
Here are the directions:
Here is my program that needs fixed:
#include
#include
//Returns the number of characters in usrStr
int GetNumOfCharacters(const char usrStr[]) {
/* Type your code here. */
int count = 0;
int i = 0;
for(i=0; i count++; return count; } void OutputWithoutWhitespace(const char usrStr[]){ printf("string with no whitespace: "); int i = 0; for(i=0; i if(usrStr[i] != ' ' && usrStr[i] != '\t') printf("%c", usrStr[i]); printf(" "); } int main(void) { /* Type your code here. */ char usrStr[50]; printf("Enter a sentence or phrase: "); gets(usrStr); printf(" You entered: %s ", usrStr); printf("Number of characters: %d ", GetNumOfCharacters(usrStr)); OutputWithoutWhitespace(usrStr); return 0; } The grading of my program submission is here: ( As you can see, 4, 5, and 6 are incorrect. I need these to be correct. Please remember to include fgets() instead of gets(). ) (Note: 4, 5, and 6 are incorrect by one number, please fix this) Thanks!! (1) Prompt the user to enter a string of their choosing. Output the string. (1 pt) Ex: Enter a sentence or phrase The only thing we have to fear is fear itself. You entered: The only thing we have to fear is fear itself (2) Complete the GetNumOfCharacters0 function, which returns the number of characters in the user's string. We encourage you to use a for loop in this function. (2 pts) (3) In main0, call the GetNumOfCharacters0 function and then output the returned result. (1 pt) (4) Implement the OutputWithoutWhitespace0 function. OutputWithoutWhitespace0 outputs the string's characters except for whitespace (spaces, tabs). Note: A tab is \t'. Call the OutputWithoutWhitespace0 function in mano. (2 pts) Ex: Enter a sentence or phrase: The only thing we have to fear is fear itself. You entered: The only thing we have to fear is fear itself. Number of characters: 46 String with no whitespace: Theonlythingwehavetofearisfearitself
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