Possible Duplicate:
C String Concatenation
have the following code:
char *doencode(const unsigned char *input, int length)
{
//irrelevant code
}
char *fname, *lname;
char *encoded, *name;
name = fname + "|" + lname;
encoded = doencode(name, 30);
and I get this error: invalid operands to binary +
How can I combine fname & | & lname?
You cannot concatenate
char*andchar[](the"|") or any permutation of using+. Usestrncat()orsnprintf()instead and ensure the destination buffer has enough memory to store the final string.