fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdbool.h>
  4.  
  5. void *xmalloc(size_t size) {
  6. void *ptr = malloc(size);
  7. if (ptr == NULL) {
  8. fprintf(stderr, "Fatal error: Out of memory in xmalloc!\n");
  9. exit(EXIT_FAILURE); // Or abort()
  10. }
  11. return ptr;
  12. }
  13.  
  14. int main() {
  15. int *A = xmalloc(sizeof(int) * 3);
  16. A[1] = 10;
  17. char *C = (char *)A;
  18. free(C);
  19. printf("a");
  20.  
  21. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
a