logo

Crowdly

Observez le code ci-dessous : #define MAX_LEN 4096 /*! * @brief function make...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Observez le code ci-dessous :

#define MAX_LEN 4096

/*!

* @brief function make_path concatenates a dirname and a filename to provide a full path to file

* @param path_to string containing the directory of the file (NULL if file is in current dir)

* @param file_name the file basename (shall not be NULL)

* @return a pointer to the full path, allocated by the function and freed by its caller.

*/

char *make_path(char *path_to, char *file_name) {

char *full_path = malloc(sizeof(char) * MAX_LEN);

if (!path_to) {

strcpy(full_path, file_name);

return full_path;

}

if (!file_name)

return NULL;

strcpy(full_path, path_to);

strcat(full_path, "/");

strcat(full_path, file_name);

return full_path;

}

Que va-t-il se passer si la fonction est appelée avec path_to ayant une valeur et file_name étant NULL ?

More questions like this

Want instant access to all verified answers on moodle.utbm.fr?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!