Answered step by step
Verified Expert Solution
Question
1 Approved Answer
mystring_main.c #include #include mystring.h int main( int argc, char * args[]) { setbuf(stdout, NULL ); char str[100] = This Is a Test ; printf(str:%s
mystring_main.c
#include
#include "mystring.h"
int main(int argc, char* args[]) {
setbuf(stdout, NULL);
char str[100] = " This Is a Test ";
printf("str:\"%s\" ", str);
printf("str_length(str):%d ", str_length(str));
printf("word_count(str):%d ", word_count(str));
trim(str);
lower_case(str);
printf("trim(str):\"%s\" ", str);
printf("str_length(trim(str)):%d ", str_length(str));
return 0;
}
Write C program mystring.h containing the headers of following string functions, and mystring.c containing the implementations of the functions. It is not allowed to use string library string.h 1. int str_length(char *s) computes and returns the number of characters of string passed by s (including space). 2. int word_count(char *s) computes and returns the number of words of string passed by s. 3. void lower_case (char *s) changes upper case to lower case of string passed by s. 4. void trim(char *s) removes unnecessary space characters in string passed by s. Use the provided main function mystring_main.c to test the above functions, the output should be exactly like the following. Public test gcc mystring.c mystring_main.c -o ql q1 str:" This Is a Test str_length(str):25 word_count (str): 4 trim(str):"this is a test" str_length(trim(str)):14 Download the mystring_main.c and save it the c:/cp264/a3 directory. mystring.h Add code comment each function #ifndef MYSTRING_H #define MYSTRING_H int str_length(char *); int word_count(char *); void lower_case(char *); void trim(char *); #endif mystring.c #include "mystring.h" #define NULLO int str_length(char *s) { // your implementation } int word_count (char *s) { // your implementation } void lower_case(char *s) { // your implementation } void trim(char *s) { // your implementation }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