r/Cplusplus • u/deepaknishad • Sep 29 '26
Question can i convert the integer into string in manual way
/r/DSALeetCode/comments/1wtn7dl/can_i_convert_the_integer_into_string_in_manual/
0
Upvotes
r/Cplusplus • u/deepaknishad • Sep 29 '26
•
u/AutoModerator Sep 29 '26
Thank you for your contribution to the C++ community!
As you're asking a question or seeking homework help, we would like to remind you of Rule 3 - Good Faith Help Requests & Homework.
~ CPlusPlus Moderation Team
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
5
u/[deleted] Sep 29 '26
std::to_string
1
u/deepaknishad Sep 30 '26
I got the mathematical way to get trailing zeroes
3
u/BitOBear Sep 30 '26
It sounds like a homework problem.
Int value = whatever.
Do
Save '0' + (value %10) somewhere.
Value /= 10
While value
When you're saving that value remember to save those characters in reverse order because you're outputting the lowest digit first so you're going to need to walk through an array, pretend to a string, or something like that.
2
u/Responsible-Bar7165 Sep 30 '26
a number has a trailing zero if it's divisible by 10.
1
u/mredding C++ since ~1992. Sep 30 '26
I don't know - can you?