Advertisement
Guest User

example-1

a guest
Feb 15th, 2022
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #define _A_VALUE "test string"
  6.  
  7. int main(void)
  8. {
  9.   char *a = malloc(sizeof *a * sizeof(_A_VALUE));
  10.  
  11.   if (a == NULL)
  12.     return EXIT_FAILURE;
  13.  
  14.   memcpy(a, _A_VALUE, sizeof(_A_VALUE));
  15.  
  16.   printf("a = %s\n", a);
  17.  
  18.   free(a);
  19.  
  20.   return EXIT_SUCCESS;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement