3.c Implement a function called text2int. You function should accept as input a string variable sre and return an intege
Posted: Fri Jun 10, 2022 11:56 am
Question 3 continues on next page... 7 Question 3 continued.... To better describe the required functionality for the function we provide below a sample main method and the expected output. int main() { char "arr[]=["one two three", "one", "five six", ""); for (int i=0; i<4; i++) printf("%d: %d\n", i, text2int(strup(ar)) } Output: 0:123 1:1 2:56 3:0 [9 marks] Total 25 marks
3.c Implement a function called text2int. You function should accept as input a string variable sre and return an integer. The src string will always contain a space-separated sequence of words representing number names, e.g. "one two three", "four", "five six". Your function should return an integer that contains the respective digits in sequence, e.g. 123, 4, 56 respectively. If the string is empty, then the value zero should be returned. The complete list of possible words occurring in a string is depicted in the array variable digits. Your function should assume that the input string will contain only the respective words and they will always be separated by spaces (no checks required). Your function can manipulate the original input string data, or you can use the malloc/strdup functions to allocate memory or create a string replica. char "digits[] = {["zero", "one", "two", "three", "four", "five", "so", "seven", "eight", "nine") int text2int (char "src) { //Insert code here. }