Skip to content

Instantly share code, notes, and snippets.

@bitcoinbrisbane
Created April 30, 2019 03:43
Show Gist options
  • Save bitcoinbrisbane/d4ec149e6f2101183406cfb3f381dc90 to your computer and use it in GitHub Desktop.
Save bitcoinbrisbane/d4ec149e6f2101183406cfb3f381dc90 to your computer and use it in GitHub Desktop.
// Concate string
function strConcat(string _a, string _b, string _c) internal pure returns (string) {
bytes memory _ba = bytes(_a);
bytes memory _bb = bytes(_b);
bytes memory _bc = bytes(_c);
string memory abcde = new string(_ba.length + _bb.length + _bc.length);
bytes memory babcde = bytes(abcde);
uint k = 0;
for (uint i = 0; i < _ba.length; i++) {
babcde[k++] = _ba[i];
}
for (i = 0; i < _bb.length; i++) {
babcde[k++] = _bb[i];
}
for (i = 0; i < _bc.length; i++) {
babcde[k++] = _bc[i];
}
return string(babcde);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment