Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help needed in c program threads linux ! Thanx Note : Every information is given ! Exercise 4.31.40: (parsestring.c) Write a C program that does

Help needed in c program threads linux ! Thanx

Note : Every information is given !

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Exercise 4.31.40: (parsestring.c) Write a C program that does the fol- lowing until EOF: i) reads a line from standard input, including an empty line, with getline, ii) tokenizes the line based on spaces and tabs, iii) builds a NULL-terminated array of character arrays (pointers), no larger than necessary, to store a pointer to each token of the line, iv) write each token to standard output from that array of character pointers, and v) frees the array of character pointers. For instance, if the input line is one two three four, the structure built is char* parsedstring[] char** parsedstring 1100 11100 1000 1004 1008 1014 NULL 4 char* line 1004 1008 1000 O''n''e' '10't''W' 1000 ' 10' 'n' 'r' 1014 10'''''''' 'e' 'e' ' and the output is: 1 :one: 2 :two: 3 :three: 4 :four: The following are some sample, non-exhaustive test cases. Your program is expected to produce identical output. Do not prompt for input. 1 $ ./a.out 2 one two three four 3 :one: 4 :two: 5 :three: 6 :four: 7 apple orange pear lemon lime 8 : apple: 9 : orange: 10 :pear: 11 :lemon: 12 :lime: 13 14 -a -b -c -d -e -f -h 15 :-a: 16 :-b: 17 :-c: 18 :-d: 19 :-e: 20 :-f: 21 :-h: 22 4D 23 $ 24 $ cat input.txt 25 one two three four 26 apple orange pear lemon lime 28 -a -b -c -d -e -f -h 29 $ 30 $ ./a.out

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

The World Wide Web And Databases International Workshop Webdb 98 Valencia Spain March 27 28 1998 Selected Papers Lncs 1590

Authors: Paolo Atzeni ,Alberto Mendelzon ,Giansalvatore Mecca

1st Edition

3540658904, 978-3540658900

More Books

Students also viewed these Databases questions

Question

9. Explain the relationship between identity and communication.

Answered: 1 week ago

Question

a. How do you think these stereotypes developed?

Answered: 1 week ago

Question

a. How many different groups were represented?

Answered: 1 week ago