ANSWERS: 4
  • I can think of a few ways: FIRST -- to stdout void concatenate( int n, const char* str ) { printf( "%d%s", n, str ); } SECOND -- with "C-like" mentality and buffer overrun vulnerability void concatenate( int n, const char* str, char* result ) { sprintf( result, "%d%s", n, str ); } THIRD -- with C++ mentality #include <string> #include <sstream> inline std::string concatenate( int n, const char* str ) { std::ostringstream ss; ss << n; ss << str; return ss.str(); }
  • don't know the code, but convert the int to a string and then concatenate with the other string.
  • You cant directly. You first have to turn the int into a string and then you can concatenate them.
  • More easily: string a ,concatenate; int b; stringstream helper; helper << a << b; concatenate.assign(helper.str());

Copyright 2023, Wired Ivy, LLC

Answerbag | Terms of Service | Privacy Policy