From 23c29a89e9f3e505527f87f94053f0b795a36f34 Mon Sep 17 00:00:00 2001 From: fvolkanoski Date: Wed, 13 Nov 2019 23:46:19 +0100 Subject: [PATCH] Fixed the code for Visual Studio builds. --- Block.cpp | 11 ++++++++++- Block.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Block.cpp b/Block.cpp index 4db8067..88ce92a 100644 --- a/Block.cpp +++ b/Block.cpp @@ -15,7 +15,12 @@ Block::Block(uint32_t nIndexIn, const string &sDataIn) : _nIndex(nIndexIn), _sDa void Block::MineBlock(uint32_t nDifficulty) { - char cstr[nDifficulty + 1]; +#if (_MSC_VER >= 1500) + char* cstr = new char[nDifficulty + 1]; +#else + char cstr[nDifficulty + 1]; +#endif + for (uint32_t i = 0; i < nDifficulty; ++i) { cstr[i] = '0'; @@ -32,6 +37,10 @@ void Block::MineBlock(uint32_t nDifficulty) while (sHash.substr(0, nDifficulty) != str); cout << "Block mined: " << sHash << endl; + +#if (_MSC_VER >= 1500) + delete[] cstr; +#endif } inline string Block::_CalculateHash() const diff --git a/Block.h b/Block.h index 12ff6de..2aecf02 100644 --- a/Block.h +++ b/Block.h @@ -8,6 +8,7 @@ #include #include #include +#include using namespace std;