Reputation: 4680
So I have this:
char uloginName[] = "derp";
char mew[33] = "home/home/" << uloginName << "\0";
I am trying concatinate uloginName with the rest of the string that will later be converted to an array of char. But it keeps returning me an error. I don't know how to do it. Also, I must use only char[] type as of this moment; No string.
Thank you for the help.
Upvotes: 0
Views: 185
Reputation: 141958
It looks like you are looking for std::ostringstream
, which is a versatile and far less error-prone way of handling strings in C++. strcat()
, strncat
and their kin are hangovers from C
and should be used cautiously in C++.
char uloginName[] = "derp";
std::ostringstream mew;
mew << "home/home/" << uloginName;
Upvotes: 0
Reputation: 182885
char uloginName[]="derp";
char mew[33]="home/home/";
strcat(mew, uloginName);
You can use strcat
on arrays of characters, so long as there is sufficient space and they are terminated with a zero byte.
Upvotes: 2