Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need this in c and plz complete code You only have to edit the code String splitting (30 points). Complete the str-split() function in strsplit..

Need this in c and plz complete code
You only have to edit the code
image text in transcribed
image text in transcribed
image text in transcribed
String splitting (30 points). Complete the str-split() function in strsplit.. The prototype of the function is char str.split(char s, char delin) str.split O splits a string s into multiple fields separated by a delimiter delim. Each field is a string and a field can be empty. The output of the function is an array of char pointers, one for each field. The last pointer in the array is NULL, indicating the end of the fields. For example, if the delimiter is' ,', the input string a,b,c,d," has five fields. The returned array for string "a,b,c,d, " has six pointers: a pointer for each of the five fields plus a NULL pointer. Suppose the result of str.split) is stored in fields. Then the six pointers are: fields [0]: "a" fields [1]:"b fields [2]:c" fields [3]:"d" fields [4] fields [5]: NULL Note that the fields [4] is an empty string and fields [5] is NULL If the input string s does not have any delimiter, it has one field. The returned array would have two pointers: the first points to a copy of s and the second is NULL. If s is empty, the only field is an empty string. Your implementation of str.split() should dynamically allocate storage for the re- turned array and fields found in the input string. You must not change any characters in the input string. A function, free.fields), is provided in the template and called from the main function. Given a pointer returned from str.splitO, free.fields() frees the mem- ory allocated in str.split). Several test cases are hard coded in the mainO function. Optionally, the program also splits argv [1] if it is provided at command line. The expected output of the program without any arguments is available in a file called test strsplit output.txt

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

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

More Books

Students also viewed these Databases questions