I have below lines in my code written in C on unix platform. Please let me know why I am getting core dumped in closedir() function. I could successfully opened the directory specified by path.
if (opendir(MyDir) != NULL )
{
closedir((DIR *) MyDir);
exit 0;
}
MyDirmust be aconst char*to be the argument foropendir.You need the result from
opendirto pass toclosedir– you can’t just cast the path!