I'm pretty new to C++, and i got a basic question... Is there a way to put and int in a strcpy / strcat ?
1 2 3 4 5 6 7 8 9 10
char* Movie::toString()
{
char* info = newchar[100];
strcpy(info, getTitle());
strcat(info, " ");
strcat(info, getMovieID()); // Wont work
return info;
}
the goal is: The function is suppose to return a string with all the variable of the class, but some are interger. I tried strcat(info, (char*)getMovieID());
but it wont work either...
If you have to return a char *, you will have to use strcpy (or equivelent) on ss.str().c_str(), which leaves deleting the memory up to the user. The above is much safer.