main.c 780 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <malloc.h>
  8. #include <string.h>
  9. #include <inttypes.h>
  10. int
  11. main(int argc, char **argv)
  12. {
  13. char *buf, *buf1;
  14. printf("Hello World!\n");
  15. buf = malloc(1024);
  16. printf("malloc func ptr: %p\n", malloc);
  17. printf("##buf: %p\n", buf);
  18. if (!buf) {
  19. printf("malloc buf failed\n");
  20. return -1;
  21. }
  22. printf("buf ptr: %p\n", buf);
  23. memset(buf, 0, 1024);
  24. sprintf(buf, "%s", "1234\n");
  25. printf("buf: %s", buf);
  26. buf1 = strdup(buf);
  27. printf("buf1: %s\n", buf1);
  28. free(buf1);
  29. free(buf);
  30. printf("buf[65536]: %c\n", buf[65536]);
  31. return 0;
  32. }