Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Needs to be written in C Language Phase 1 In Phase 1, write a function words ) that takes a character string str as input,

image text in transcribed

Needs to be written in C Language

Phase 1 In Phase 1, write a function words ) that takes a character string str as input, and returnsa dynamically allocated, fixed-lengthed, NULL-terminated array of pointers to dynamically allocated copies of words in the given string str. That's a mouthful, but the underlying idea i:s really simple:) The function can be declared as: char **words char *str The words in str are separated by whitespace, i.e. blanks, tabs, and newlines. The words () function detects all words in str, copies each word into some new space allocated by malloc ), and returns an array with pointers to these new spaces. The array can be of some fixed length, say 64, but will have as many pointers as the number of words in str, followed by a NULL pointer. As an example, if str "Rajiv Bagai rocks ! ! ", then it has 3 words, namely "Rajiv", "Bagai", and "rocks!!". After making copies of these 3 words, the words function will return an array of 64 pointers. Only the first 4 elements in the array will have useful pointer values, namely to the newly created copies of these 3 words, and NULL As a final detail, if str has more than 63 words, just ignore the extra ones. Note: There are many other ways of accomplishing the above breakup of a string into words, like using a static, global array of pointers, etc. As long as you make Phase 2 work, feel free to employ any design for Phase

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

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

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions

Question

When should you avoid using exhaust brake select all that apply

Answered: 1 week ago

Question

Describe the concept of corporate social responsibility.

Answered: 1 week ago

Question

Explore the concept of business ethics.

Answered: 1 week ago

Question

Discuss human resource management issues for small businesses.

Answered: 1 week ago