I am passing a C Macro to a function which receives it as char *. Without any reason the last character from macro gets truncated. I doubt some memory leak, but could not find where.
#define FROM "/some/local/path/from/"
#define TO "/some/local/path/to/"
....
char file[_D_NAME_MAX + 1] = {'\0'};
....
funMove(file, FROM, TO);
....
....
int funMove(char *file, char *from, char *to) {
//here the to value is one character less (/some/local/path/to) slash got truncated
}
Apologies!! Actually, nothing was wrong with the code and the macro didn’t get truncated but got overridden. There was another macro with the same name and content except the slash. So, the macro was got replaced instead of the intended one.
I just had the header file 2 in mind and misunderstood that the macro got truncated. Actually, the macro from header file 1 was used instead of file 2 which was the intended one.
Thanks for all your answers and support.