I am trying to combine the string NCards and Scards into one string called Tcards.
I am using # include <cstring> and I get an error. How would I fix this. All the variables are strings.

void deck::deal()
{
	Tcards=strcpy(Scards, Ncards);
	

}

strcpy(dest,source) copies the source to the destination
EDIT: strcpy returns the destination string, you're treating it like it returns a concatenated one.

What you need is to strcpy Scards into Tcards and then use strcat to add Ncards to Tcards. Make sure Tcards is big enough to take on both strings.

Need more input. What is the declaration for the xCards? If they are Cstyle strings then you can't assign one to the other and if they are STL string objects then they won't work with strcpy().

For Cstyle strings there is a strcat() function that will concatenate one string onto the other, assuming the first string has enough space to accomate the second string. Then, once you have concatenated B onto A you can copy A into C with strcpy.

For STL string objects you can use the + operator to concatenate B onto A and then use the assingment operator to assign the new, modified and longer A to C.

Edit: Need to type faster.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.