Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. const char *const test_string = "test string";
  2. const size_t test_string_length = strlen(test_string) + 1;
  3. const size_t arr_size = 16;
  4. char mallocated = malloc(arr_size + sizeof(char));
  5. if(test_string_length <= arr_size){
  6.     memcpy(mallocated, test_string, test_string_length);
  7.     printf("Copied with offset = %s\n", mallocated + 5);   // <------- Here
  8. } else {
  9.     fprintf(stderr, "The string %s is too long\n", test_string);
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement