123456789101112
char buf[300]; int main() { char *mc_no ="002"; int a=99; //i did something like this:- strcat(buf,mc_no); strcat(buf,","); strcat(buf,a);//error here argument of type int incompatible with type const char * return 0; }
12
i want an output like this :- 002,99
1234
char a [2] = "99"; //... strcat (buf, a); //...
12345678910111213141516
#include <cstring> #include <cstdio> char buf[300]; int main() { const char *mc_no = "002"; int a = 99; std::strcat( buf, mc_no ); std::strcat( buf, "," ); std::sprintf( buf + std::strlen( buf ), "%d", a ); return 0; }