Execution of printf() and Segmentation Fault
This is due to stream buffering of stdout. Unless you do fflush(stdout) or you print a newline “\n” the output is may be buffered. In this case, it’s segfaulting before the buffer is flushed and printed. You can try this instead: or: