git repos / blockattack-game

commit e35fb006

sago007 · 2016-06-05 13:53
e35fb00668e8dd9b135a7cd933a2151f682b82d8 patch · browse files
parent 2488b1f5d698ba18bd6306a7766d34a50e0e1e5f

Simpler way to make an integer with minimum 2 digits

Changed files

M source/code/BlockGame.cpp before
diff --git a/source/code/BlockGame.cpp b/source/code/BlockGame.cpp index 5db2cc9..b993d89 100644 --- a/source/code/BlockGame.cpp +++ b/source/code/BlockGame.cpp
@@ -41,18 +41,11 @@ using std::stringstream;
using std::cerr;
using std::vector;
-
-static stringstream converter;
-
//Function to convert numbers to string (2 diget)
static string itoa2(int num) {
- converter.str(std::string());
- converter.clear();
- if (num<10) {
- converter << "0";
- }
- converter << num;
- return converter.str();
+ char buffer[20];
+ snprintf(buffer, sizeof(buffer), "%02i", num);
+ return buffer;
}
stageButton stageButtonStatus;