Hi! segmentation fault

I have written a program which takes a directory as command line arguments and displays all the dir and files in it.
I don't know why I have a problem with the /etc directory.It displays all the directories and files untill it reaches a sub directory called peers which is in /etc/ppp/peers.the output stops there and says "segmentation fault".I don't know why I have this problem.Any help is greatly appreciated.Thank you.

It might have to do with the string length. We cant comment until we see the code. Or better, compile your code with -g3 -ggdb3 flag and then run it through gdb. That should tell you whats happening.

Hi vino!
Thanks for ur quick reply.
I never tried what u said.
Can u tell me in detail?

Most C compilers are going to issue errors/warnings with your code. You have some problems.

First suggestion to fix one issue - #include <limits.h>

Usually dealing with full filenames means declare your strings like this with PATH_MAX

   char mydir[PATH_MAX]={0x0};

Plus, what you're doing is far easier with ftw() - see man ftw

Thanks Jim! Greatly appreciate ur suggetion.