logo

Crowdly

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

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

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 ?

Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на moodle.utbm.fr?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!