You do this a lot without allocating more space, which is very bad:
Code:
strcat(dest, "/");
strcat(dest, src);
Here dest is a pointer to one of main()'s argv parameters; you do something similiar with the same pointer again when it is copied into some of your functions. Would you consider this acceptable:
Code:
char eg[]="hello world,";
strcat(eg, " okay, no space allocated for this!");
If so, you do not understand arrays in C properly -- you should figure out or ask why this is wrong before you do ANYTHING else. If you do not fix this, eventually your program will start seg faulting (I'm surprised it doesn't now; very likely it will if you compile it on a machine with a slightly different compiler or architecture).
If you do understand but had forgotten the issue of proper memory management because you are new to C, I'd suggest you use something like this:
Code:
#include <limits.h>
[....]
char dest[PATH_MAX+1];
strcpy(dest, av[2]);
PATH_MAX is a system constant found in limits.h on *nix systems. It represents the maximum length, in bytes, for an absolute file path. Ie, no filename including the path can possibly be longer than that (usually it is 4096). So if you are just building paths in there, it will be long enough to hold all your strcat's, etc.