Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C function called secondWord that has the prototype char* secondWord(char* inputString, char* outputString); Your function should do the following: Prompt the user to

Write a C function called secondWord that has the prototype

char* secondWord(char* inputString, char* outputString);

Your function should do the following:

Prompt the user to enter three to five words seperated by spaces or tabs

Finds the second word (separated by spaces or tabs in inputString)

Copies the second word into outputString

Returns a pointer to outputString

The data inside inputString is not changed by this function

It can be assumed that inputString is less than 150 characters

It can be assumed that outputString is able to support the length of the second word

If inputString contains no second word, the function should put a NULL into outputString and return a NULL

For an inputString of “One Two Three Three Four” the outputString should be:

“Two”

For an inputString of “OneTwoThreeThreeFour” the outputString should be:

NULL

Write a C program in Code::Blocks to test your secondWord function from 3 (part 3 should be a function inside part 4’s completed code)

This program should create at least 10 use cases for the function that tests its behavior under different input conditions. These use cases are hard coded (no user input). Your code should be able to test any version of the secondWord function (it should be able to test another student’s secondWord function to confirm it operates correctly).

Test cases must include inputs with only 1 word, 2 words, 3 words, use of tabs, use of spaces, uses of tabs and spaces, capital letters, numbers, punctuations, appropriate combinations of test input.

The program should have a known expected output for each example and test the output to see if the output matches this expected output.

The program will output to the terminal and a txt file

The program will output information about what is being tested (secondWord)

The program will output “Function Test Case #” followed by the number of the test case, then output “Input: ” followed by the input, “Expected Output:” followed by the expected output, and “Output: “ followed by the output for each case. The program will print out a “PASS” or a “FAIL” after each output line. Output can be formatted on separate lines as shown below to make things easy to read.

The program will print out a “PASS” or “FAIL” at the end of the output for the whole function test. A FAIL is outputted if any individual test fails.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

include include include char secondWordchar inputString char outputString int count 0 char data100 inti intcnt 0 for i 0 i 0 strcpyoutputStringdata br... 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: 3

blur-text-image

Document Format ( 2 attachments)

PDF file Icon
6095da653b18c_26321.pdf

180 KBs PDF File

Word file Icon
6095da653b18c_26321.docx

120 KBs Word File

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

Discovering Advanced Algebra An Investigative Approach

Authors: Jerald Murdock, Ellen Kamischke, Eric Kamischke

1st edition

1559539844, 978-1604400069, 1604400064, 978-1559539845

More Books

Students also viewed these Programming questions

Question

What will the figures in each case actually represent?

Answered: 1 week ago