Advertisement
Radfler

::string_concat

Sep 23rd, 2015
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. char* string_concat(const char* lhs, const char* rhs) {
  6.  
  7.     const size_t storage_size = strlen(lhs) + strlen(rhs) + 1;
  8.     char* storage = malloc(storage_size);
  9.  
  10.     strcpy(storage, lhs);
  11.     strcat(storage, rhs);
  12.  
  13.     return storage;
  14.  
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement