I am trying to output 00001 instead of just 1, so I do this:
char pos[5];
sprintf(pos, "%05d", 1);
string Index = (string) pos;
It works just as I'd expect - if I cout << Index it says 00001
However, it is breaking something totally unrelated. On the next line, I access an element of a vector
geom_Vector3 T = Translations[SceneIndex];
(Translations was declared as vector<geom_Vector3> and filled before any of this).
If I get one of the elements of the vector with the 3 sprintf lines commented, it works fine. If I run the 3 sprintf lines before accessing the element, it is filled with garbage.
1) Why is it doing this??
2) Is there a better, less "c style" way to turn an integer in to a 5 digit integer with leading zeros that will prevent this all together?
Thanks!
Dave