Right.
There's a problem in your whole code. char is just one character. lines 11 and 13 will only allow lingle char names. Function concat will only return one char (if it was written correctly).
If you want to have strings either use char arrays and deal with a lot of problems that come with them, or use std::string.
Hamster bhai! I am just a beginner. I din't get much of what you said.
One more thing: i used char type with c++ for the first time. May be it's not there at all.
And i'm not familiar with strings either! But thanks for your concern.
As paki programmer said. Using string is much wiser in this situation. According to the comments in your code you want to concat the first and last name so it's impossible to fit these into a single char as they only take one letter.
Now if you want to use alot of string and combine them you should use the std::stringstream class, which you can add string with the << operator, then using the .str() to get the concatenated string.
string concat(string a, string b)
{
cout<<a<<" "<<b;
return (a,b);
}
In general try using the reference in your parameter to avoid unnecessary copying of the source, as the
the original method above will create a copy of both string a and b.
1 2 3 4 5
string concat(string & a, string & b)
{
cout<<a<<" "<<b;
return (a,b); // Can you actually write like this?
}