Guest User

Untitled

a guest
Jan 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. pragma solidity ^0.4.19;
  2.  
  3. contract MyStringTest {
  4.  
  5. function strConnect() public constant returns(string){
  6.  
  7. string memory str1 = "abc";
  8. string memory str2 = "def";
  9. bytes memory strbyte1 = bytes(str1);
  10. bytes memory strbyte2 = bytes(str2);
  11.  
  12. bytes memory str = new bytes(strbyte1.length + strbyte2.length);
  13.  
  14. uint8 point = 0;
  15.  
  16. for(uint8 j = 0; j < strbyte1.length;j++){
  17. str[point] = strbyte1[j];
  18. point++;
  19. }
  20. for(uint8 k = 0; k < strbyte2.length;k++){
  21. str[point] = strbyte2[k];
  22. point++;
  23. }
  24. return string(str);
  25. }
  26. }
Add Comment
Please, Sign In to add comment