Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Write C programs named mystring.h and mystring.c , containing the headers and implementations of the following functions. int letter_count(char *s) computes and returns the number

Write C programs named mystring.h and mystring.c, containing the headers and implementations of the following functions.

  1. int letter_count(char *s) computes and returns the number of English letters in string s.
  2. int word_count(char *s) computes and returns the number of words in string s.
  3. void lower_case(char *s) changes upper case to lower case of string s.
  4. void trim(char *s) removes the unnecessary empty spaces of string s.

mystring.h

#include 
 
int letter_count(char *);
void lower_case(char *);
int word_count(char *);
void trim(char *);

mystring.c

#include "mystring.h"
 
int letter_count(char *s) 
{
// your implementation
}
 
void lower_case(char *s) {
// your implementation
}
 
int word_count(char *s) {
// your implementation
}
 
void trim(char *s) {
// your implementation
}

Use the provided main function to test the above functions.

#include "mystring.h"
 
int main(int argc, char* args[]) {
 setbuf(stdout, NULL);
 char str[100] = " This Is a Test ";
 printf(" Input string: \"%s\"", str);
 printf(" Letter count:%d", letter_count(str));
 printf(" Word count:%d", word_count(str));
 trim(str);
 printf(" After trimming:\"%s\"", str);
 lower_case(str); 
 printf(" After lower case:\"%s\"", str);
 return 0;
}

output should look like this:

Input string: " This Is a Test "
Letter count:11
Word count:4
After trimming:"This Is a Test"
After lower case:"this is a test"

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_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

More Books

Students explore these related Databases questions