Ok what I need to get is a file name that is in the format of:
001
002
003
...
010
I need those leading 0's
Neil said it was possible to use stringstream.
my code is:
xx is a for loop variable it just increments starting at 1.
I can't seem to figure out why I can't get the leading 0's to show up. Maybe someone who has used this before could shed some light on the situation?
stringstream ss; char prev = cout.fill('0'); cout.width(3); ss << xx; temp = ss.str();
got it sorta working with this code
ss.width(3); ss.fill('0'); ss << xx; temp = ss.str(); ss.ignore(3);
although the ignore ignores the next 3 characters and not the current buffer. I did try flushing as well, but it seemed to have no effect.
This seems to be the solution as put forth by the standard:
ss.str("");
This works with strings, which I am using so it saves a step. sprintf would be great if your looking for c and not C++ or using char*'s and not string classes.
The only problem was that how to clear the buffer was not clearly defined from where I found it.
The proper method being:
ss.str("");
I'm not sure if this will help you but the way I converted my strings to wide chars was like this. I take ints and convert them to string, then I concatenate a large number of them to a single string and then copy them over to a wchar*. Hope it helps.
EDIT
What you could do is take your integer and convert that to a string and then use the size() method to find the number of single integers in your first integer. I did the below code in the a.cc text input without compiling it so it might not work.
I did the below code in the a.cc text input without compiling it so it might not work.
It doesn't really matter whether that way would work or not as it's completely the wrong way to do it. The way Peter demonstrated is the best way to do it in C++.
It doesn't really matter whether that way would work or not as it's completely the wrong way to do it. The way Peter demonstrated is the best way to do it in C++.
Oh, I didn't know he solved it. I wasn't sure what Adam meant after he posted the answer.
Adam
Where do you get this stuff?
Who is Adam? Now I am confused.
Who is Adam? Now I am confused.
I mixed up your name sorry. I didn't think anyone would care or notice.
Huh?! David....Adam.....yep completely easy to mix them up
.
Shut up, Carl.
Alright CMA Lisa... Oh f*ck, You're the Country Music Awards, hell has come to A.cc
.