I have this code:
string username;
string node;
string at;
string final;
struct passwd* user_info = getpwnam("mike");
struct utsname uts;
uname(&uts);
username = user_info->pw_name;
node = uts.nodename;
at = "@";
final = username + at +node;
i=strlen(final[0]);
char *pp = new char[i];
strcpy(pp,final);
fputs(pp, stdout);
I just want to convert these 3 strings in one char*. I know my code is totaly wrong but I test a lot of things through google. Can somebody help me please?
You simply need to use strings::c_str()
If you need to get the string data in a
char*and notconst char *then you need tocopyit as such: