Question
c programming - the following program should be able to print out total number of whitespace, but instead it prints out the number of white
c programming - the following program should be able to print out total number of whitespace, but instead it prints out the number of white spaces in 3 different lines.
Input in command line: $ counter Output: 18 15 26 It Should be just like a total of whitespace. ******************************************************************************** #include #include #include int whiteSpace(char *s) { int counter = 0; int i = 0; while(s[i]) { if(isspace(s[i])) counter++; i++; } return counter; } int others(char *str) { int len,result; len = strlen(str); result = len - whiteSpace(str); return result; } int main() { char test[1000]; int whitespace; int other; while(fgets(test, 1000, stdin)) { whitespace = whiteSpace(test); printf("%d ", whitespace); } return 0; } inputQuote: There is a tide in the affairs of men, Which taken at the flood, leads on to fortune. Omitted, all the voyage of their life is bound in shallows and in miseries. On such a full sea are we now afloat. And we must take the current when it serves, or lose our ventures. Read more at: https://www.brainyquote.com/quotes/quotes/w/williamsha395459.html
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