Question: language: C Write the file parse.c with the the following functions. Include parse.h as the header Write a function int count_tokens(char* str) that gets a

language: C

Write the file parse.c with the the following functions. Include parse.h as the header

Write a function int count_tokens(char* str) that gets a string and counts the number of tokens in str. A token is any substring separated from others by spaces. Examples: On input "ABC ) 123 !!" the function will return 4. On the input "( 8 + ( 41 - 12 ) )" the function will return 9. **You may assume that tokens are separated by a single space, and there are no spaces neither before the first token not after the last token. 2) Write a function char** get_tokens(char* str, int n_tokens) that gets a string, and the number of tokens obtained in count_tokens, and returns an array of strings, where the ith element of the array contains the ith token. Example: On input str = "( 8 + ( 41 - 12 ) )" and n_tokens = 9 the function returns the array ["(", "8", "+", "(", "41", "-", "12", ")", ")"]. ** You may assume that tokens are separated by a single space, and there are no spaces before the first token, and no spaces after the last token.

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!