I have to concatenate all the numbers in a string to another one.
char *cif = "1234567890";
char s[100], s1[40] = "", s2[40] = "";
cin.getline(s, 100);
for (int i=0; i<strlen(s); i++)
if (strchr(cif, s[i]))
strcpy(s1+1, s[i]);
But I get:
error: invalid conversion from 'char' to 'const char*' [-fpermissive]|
You can use
std::stringand itsoperator+to concatenate strings:Live Demo
In your code its not actually clear what you want to concatenate with what. I hope the above is clear enough to concatenate any string with any other. Note that non-const pointers to string literals is no longer allowed since C++11 and you need a
const char*.