string append char cpp code example
Example 1: c++ append a char to a string
#include <iostream>
#include <string>
int main ()
{
std::string name ("John");
std::string family ("Smith");
name += " K. ";
name += family;
name += '\n';
std::cout << name;
return 0;
}
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();
}