I,
I come across a strange problem when using strlcat, as follows:
Code:
static int get_path(char *parent, char * file){
int parent_len = strlen(parent);
int file_len = strlen(file);
if(parent_len + file_len > 256) {
return 0;
}
int ret = strlcat(parent, file, file_len);
}
int main(int argc, char *argv[]) {
char path[256];
char file[256];
snprintf(path, 256, "%s", "./parent/");
snprintf(file, 256, "%s", "test.dat");
get_path(path, file);
cout << path << endl;
cout.flush();
}
The output is :
./parent/
The problem is why the output is "./parent/"? Is it supposed to be "./parent/test.dat"?
Thanks
Xiong