I know the problem . but can't resolve it

Whenever i print output in function it works but if i try to push it in the vector and print in main, it changes each value to the value of last character corresponding to input.
for example:
if input is 34
if i print output in the funtion , it prints alright
something like : dg , dh , di , eg,eh,ei , fg,fh,fi

but if i push it in vector and print it in main, it changes all the values to ‘fi’
I don;t know why it is happening.

Hey @chetan_aggarwalbX1 i got your doubt, I’ll debug your code and let you know where you are getting struct , till then you can move on to your next question :blush:

Okay , thankyou ! and one more thing , even tho i have watched all the videos and practicing questions , i am unable to think the approach myself for recursion . I dont know what to do

You are unable to think for an approach for this problem @chetan_aggarwalbX1?

I am able to think of approach , but after seeing a similar problem , not naturally

I have to see the solution or similar problem everytime

I’ll debug your code and tell you your mistake. From tht you can take reference :blush:

hey @chetan_aggarwalbX1 , I found your mistake. You have declared a global vector like :
vector<char > v;
instead of making it a char
make it string and, convert your output character array into string of variable temp and then push it in vector , by doing this you will get your desired output :smile:
Do these changes in
line number 3 : vector < string > v;
line number 17 : string p(out); v.push_back( p );
and then print it in main :smile:

the vector is of char* type , not char type!

That’s the reason it won’t work cause it’s a pointer pointing to character variable and we to store entire array not just the first letter of array :smile:

okay ! it worked . I didn’t knew it will cause problem with char* and string

Thankyou for your help.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.