append number to string c++ code example
Example 1: int and string concatination cp[
std::string name = "John";
int age = 21;
std::string result;
result = name + boost::lexical_cast<std::string>(age);
result = name + std::to_string(age);
fastformat::fmt(result, "{0}{1}", name, age);
fastformat::write(result, name, age);
result = fmt::format("{}{}", name, age);
std::stringstream sstm;
sstm << name << age;
result = sstm.str();
char numstr[21];
result = name + itoa(age, numstr, 10);
char numstr[21];
sprintf(numstr, "%d", age);
result = name + numstr;
char numstr[21];
result = name + stlsoft::integer_to_string(numstr, 21, age);
result = name + winstl::int_to_string(age);
result = name + Poco::NumberFormatter().format(age);
Example 2: appending string in c++
#include<iostream>
#include <string>
int main() {
std::string namee = "Caleb";
namee += " Hello";
std::cout << namee << std::endl;
std::string namee2 = std::string("Caleb")+" Hello";
std::cout << namee2 << std::endl;
std::cin.get();
}