fork download
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. typedef struct
  6. {
  7. int field;
  8. } myStruct;
  9.  
  10. void myFunc(myStruct *ptr)
  11. {
  12. if (ptr == NULL)
  13. {
  14. printf("Pointer is null!");
  15. }
  16. // rest of code
  17. }
  18.  
  19. int main()
  20. {
  21. myStruct *ptr = NULL; // tried both *ptr; and *ptr = NULL;
  22. memset(&ptr, 0, sizeof(ptr));
  23. myFunc(ptr);
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
Pointer is null!