Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write the function int strend ( s , t ) , which returns 1 if the string t occurs at the end of the string
Write the function int strend stwhich returns if the string t occurs at the end of the string sand returns zero otherwise. The provided program tests your function by first prompting the user for the string to search and then promoting the user for the string to search for. The program calls your strend with the users input and displays a message indicating that the string was found or was not found. The strend function must not print any information to the console. The only output from this program should be from the provided program.
The provided program:
#include
#include
CONSTANTS
typedefs and structures
globalVariables
FunctionPrototypes
int strendchar s char t;
char TrimRightchar str const char trimChars;
Function: main
Parameters:
argc main parameter for argument count
argv main parameter for argument values
int mainint argc, char argv
char baseString;
char findString;
Obtain the string to search
printfEnter a string: ;
fgetsbaseString sizeofbaseString stdin;
TrimRightbaseString NULL;
Obtain the string to search for
printfEnter string to search for: ;
fgetsfindString sizeoffindString stdin;
TrimRightfindString NULL;
strend returns if there is a match
if strendbaseString findString
printfSearch string was found!!
;
else
printfSearch string was not found.
;
Function: strend
Parameters:
s string to search
t string to search for
int strendchar s char t
int retVal ;
YOUR IMPLMENTATION GOES HERE
return retVal;
TrimRight
Removes characters from the end of a string, defaults to whitespace
characters is trimChars is null.
char TrimRightchar str const char trimChars
int i;
if trimChars NULL
trimChars t
vfr ;
i strlenstr;
while i && strchrtrimChars stri NULL
stri;
i;
return str;
IN C
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