c++ i want to concat char but i get an segmentation fault -
i have short question how concat these char in c++. segmentation fault
struct dirent *ent const char *filepath = strcat("/test/",ent->d_name) ;
the c way concatenate strings this:
char buf[128]; strcpy(buf, "first string"); strcat(buf, "second string"); first allocate space hold concatenated strings. copy first string buffer. concatenate second string onto first.
but since you're using c++, should use std::string instead of str* functions.
std::string j = "hello"; j += " there";
Comments
Post a Comment