Search code examples
ccoredump

how do I fix core dump?


I am getting core dump by this little programm.

#include <dirent.h>
int main(void) {

        printf("process n%s",(long)getpid());
        exit(0);
}

can you explain me why?


Solution

  • You need to know where your functions come from, what they're returning and how to print the return value.

    #include <unistd.h>
    #include <stdio.h>
    
    int main(void) {
        printf("process n%ld", (long)getpid());
    }