Originally Posted by
gustavosserra
I already tryied printf, but it does not fill with '0'. I need string stream because I do not want to write to the screen.
Then you didn't use it correctly, nor dud you use the proper function.
Code:
stringstream str;
str.fill('0');
str.width(2);
str << (currentTime-initialTime)/60;
str << ':';
str.width(2);
str << (currentTime-initialTime)%60;
string str2;
str >> str2;
would become
Code:
sprintf(str, "%02d:%02d", (currentTime-initialTime)/60, (currentTime-initialTime)%60);
Writes to the char buffer str, zero filled.