L'obiettivo del mio programma è quello di immagazzinare i nomi di file presenti in una data directory con il loro nome completo (i.e. percorso completo). Per fare ciò prima uso la funzione readdir() per scrivere i nomi dei file in un array di char chiamato id_n, e poi con la funzione strcat() vorrei creare una stringa che contenga la directory + il nome del file (ovvero il percorso completo del file)...solo che non riesco a fare questo ultimo passaggio in quanto non riesco ad unire la stringa contenente il nome della directory con una delle stringhe contenute in id_n. Qualcuno può aiutarmi? Grazie

Qui sotto riporto il codice completo del programma che ho scritto fino ad ora:
codice:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <dirent.h>
#include <errno.h>

int err_malloc(char s[]);
 
int main(int argc, char *argv[])
{
        DIR *dip;
	FILE *dFile;
        struct dirent *dit;
	struct stat buf;
        int i = 0, n, sized, sizef, sizeft, sizetot;	//sized e sizef are integer that contains the number of character rispectively of directory name and file name
 
        /* check to see if user entered a directory name */
        if (argc < 2){
            printf("Usage: %s <directory>\n", argv[0]);
            return 0;
        }

	sized=strlen(argv[1]);
	printf("Control: directory name contains %d characters\n",sized);
 
        /* DIR *opendir(const char *name);
         *
         * Open a directory stream to argv[1] and make sure
         * it's a readable and valid (directory) */
        if ((dip = opendir(argv[1])) == NULL){
            perror("opendir");
            return 0;
        }
 
        printf("Directory stream is now open\n");
 
        /*  struct dirent *readdir(DIR *dir);
         *
         * Read in the files from argv[1] and print */
	sizef=0;
        while ((dit = readdir(dip)) != NULL){
	    if(strcmp(dit->d_name, ".") != 0 && strcmp(dit->d_name, "..") != 0){
                printf("\n%s", dit->d_name);
		sizeft=strlen(dit->d_name);
		if(sizeft>sizef) sizef=sizeft;
		i++;
	    }
        }
	n=i;   //number of file in a directory
	sizetot=sized+sizef+1;	//maximum length for the string containing the complete path of a file
	printf("Control: the longest file name has %d characters\n", sizef);

        printf("\nreaddir() found a total of %i files\n", n);
	rewinddir(dip);

	char *id_n[n];
	i=0;
	while ((dit = readdir(dip)) != NULL){
	    if(strcmp(dit->d_name, ".") != 0 && strcmp(dit->d_name, "..") != 0){	        
		*(id_n+i)=dit->d_name;
	    	i++;
	    }
	}
	
         /* int closedir(DIR *dir);
         *
         * Close the stream to argv[1]. And check for errors. */
        if (closedir(dip) == -1){
            perror("closedir");
            return 0;
        }

	for(i=0; i<n; i++){
	    printf("%s\n", *(id_n+i));
	}
 
        printf("\nDirectory stream is now closed\n");

	char filename[sizetot];	//filename it will be the final string containing the full name of a file
	filename[0]='\0';	//inizializzo la variabile filename per evitare caratteri strani al suo interno
	strcat(filename, argv[1]);
	strcat(filename, id_n[1]);
	printf("%s, %s\n",filename, *(id_n+1));

        return 1;
}

int err_malloc(char s[])
{
    printf("out of memory while allocating %s.\n", s);
    return 1;
}