Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!