is there a way to tell the program to remove a certain charecter or number from a string with out giving it a position. for example i have a program that asks the user to enter a set of numbers and the program reverses the order of the numbers. so if the user entered 12340 theprogram should print out 4321. but my program prints out 04321. i cant make it not print out the zero when it is at the front. but I need it to print out the zeros when they are at the end. for example if the user enters 01234 the program needs to print out 43210. you see. I need help please.
bigben09
0
Junior Poster in Training
Recommended Answers
Jump to PostWhat I would do is flip the number like you mentioned, but instead convert the number back to an integer with a stringstream.
std::stringstream myStream; int completeNumber; myStream << backwardsNumber; myStream >> completeNumber;
When you convert the number back to an integer, any leading 0s will automatically …
Jump to PostProbably the best idea would be to store the reversed number in a string before outputting it to the screen on-the-fly. That way you can manipulate the string anyway you want.
Or you could simply do the leading 0s check before you print out the char; you'd need a …
Jump to Postyeah this is al going way over my head i am new to this. could u show me were it would go in my program. that would help me alot. i posted my prograam up top u can run it and see how it works if you would like.
Look, …
Jump to PostHow about showing us your updated code. And please use code tags this time around.
Jump to PostIf you had looked at the watermark in the quick reply box, read forum anouncements here, read the rules or even read my signature you would have seen this link somewhere.
All 36 Replies
harleyrica
0
Newbie Poster
John A
1,896
Vampirical Lurker
Team Colleague
bigben09
0
Junior Poster in Training
bigben09
0
Junior Poster in Training
John A
1,896
Vampirical Lurker
Team Colleague
bigben09
0
Junior Poster in Training
John A
1,896
Vampirical Lurker
Team Colleague
bigben09
0
Junior Poster in Training
John A
1,896
Vampirical Lurker
Team Colleague
bigben09
0
Junior Poster in Training
bigben09
0
Junior Poster in Training
John A
1,896
Vampirical Lurker
Team Colleague
bigben09
0
Junior Poster in Training
John A
1,896
Vampirical Lurker
Team Colleague
bigben09
0
Junior Poster in Training
John A
1,896
Vampirical Lurker
Team Colleague
bigben09
0
Junior Poster in Training
bigben09
0
Junior Poster in Training
bigben09
0
Junior Poster in Training
John A
1,896
Vampirical Lurker
Team Colleague
bigben09
0
Junior Poster in Training
John A
1,896
Vampirical Lurker
Team Colleague
bigben09
0
Junior Poster in Training
John A
1,896
Vampirical Lurker
Team Colleague
bigben09
0
Junior Poster in Training
John A
1,896
Vampirical Lurker
Team Colleague
bigben09
0
Junior Poster in Training
bigben09
0
Junior Poster in Training
bigben09
0
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.