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

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -