But return_dir is not initialized. Trying to write there is undefined, and can cause real problems.
Once you fix that, I'm not sure what precisely your program is trying to do. But there's an issue with this:
Code:
dir_path = strcat(dir,"/");
dir_path = strcat(dir_path,dp->d_name);
Here you are modifying the string contained in dir. This means you are modifying the original string as passed to the function. An easy way around this is something like:
Code:
ff_gather(data, dp->d_name);
chdir("..");
and nothing else inside your if block.
Whether this works depends on your needs.