int x = 12345; We have to convert this int into a string without using STL.
How to convert int into a string without using any library like to_string()
The algorithm is easy to see in English.
Given an integer, e.g. 123
- divide by 10 => 123/10. Yielding, result = 12 and remainder = 3
- add 30h to 3 and push on stack (adding 30h will convert 3 to ASCII representation)
- repeat step 1 until result < 10
- add 30h to result and store on stack
- the stack contains the number in order of | 1 | 2 | 3 | …
But it is difficult to implement.
For code and more information, you can also refer this.
I tried implementing it but it showing an error.Code is in the link.
Can you implement it.
See this your correct code
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.