Question: In C + + Given two functions: int extractInt ( const char src [ ] , int& index,int& depth ) , which extracts the first

In C++
Given two functions:
int extractInt(const char src[], int& index,int& depth), which extracts the first few digits from array src[] until ecountering a "{", and converting into integers, i.e. char src[]="4321{a}72{b}" would only return 4321 in integer form, and is safe to assume the first characters until the first "{" are all digits.
Another function void repeatString(char str[], int repeat_times, char repeated_str[]) would repeat str[](repeat_times) times and save into repeated_str[], i.e. for str[]= "abd", repeat_times =3, repeated_str would be "abdabdabd".
Use these two defined functions to constuct another function:
void recursiveDecode(const char src[], int& index, char decoded[]),
where src[] would be the input string, and decoded[] would be the decoded string, demonstrated below:
src[]="a2{ba}"--> decoded[]= ababa
src[]='ab3{a1{b{2{fb}}}}'--> decoded[]= ababfbfabfbfabfbfb
In other words, the strings in the brackets would be repeated multiple times determined by the integers before it, where the integers could be many digits.
It can be assumed that {} would only have integers before it, i.e.2{a}, while a{a} would be invalid and would not appear in the inputs. Nested brackets however, are possible.
Write the final function in terms of the functions defined, with no added parameters, only usable libraries are and .
And DO NOT use any while or for loops for the function, only recursion is allowed

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 Accounting Questions!