Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function named checkMessages that accepts an array of pointers to C-strings (array of characters with NULL terminating character) and its size.
Write a function named "checkMessages" that accepts an array of pointers to C-strings (array of characters with NULL terminating character) and its size. It checks to see whether the array of messages that contains any message that begins or ends with '-' or has it in the middle of the array.
It will return the following three values: - the number of messages that begins with '-' - the number of messages that ends with '-' - the number of messages that begins and ends with '-'
Here is an example of test data and its expected return values int main() { char msg1[] = "One" ; char msg2[] = "-Two" ; char msg3[] = "-Three-" ; char msg4[] = "Fou-r" ; char msg5[] = "-Fiv-e" ; char * msgSet1[] = {msg1} ; // with this array, the function will return 0 begins, 0 ends and 0 both. char * msgSet2[] = {msg1, msg2} ; // with this array, the function will return 1 begin, 0 end 0 both char * msgSet3[] = {msg1, msg2, msg3} ; // with this array, the function will return 2 begins, 1 end and 1 both char * msgSet4[] = {msg1, msg2, msg3, msg4} ; // with this array, the function will return 2 begins, 1 end and 1 both char * msgSet5[] = {msg1, msg2, msg3, msg4, msg5} ; // with this array, the function will return 3 begins, 1 end and 1 both char * msgSet6[] = {msg3} ; // with this array, the function will return 1 begin, 1 end and 1 both return 0 ; }
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