c++ tutorial str library code example
Example 1: c++ string manipulation
string sString = "Programming";
cout << "|" << sString << "|" << "\t\t << [No manipulation]" << endl;
cout << "|" << setw(20) << sString << "|" << "\t << [Width:20][align:string_default=right]\n";
cout << "|" << setw(20) << right << sString << "|" << "\t << [Width:20][align:right]\n";
cout << "|" << setw(20) << left << sString << "|" << "\t << [Width:20][align:left]\n";
cout << "|" << setw(20) << -31.05 << "|" << "\t << [Width:20][align:int_default=left]\n";
cout << "|" << setw(20) << internal << -31.05 << "|" << "\t << [Width:20][align:internal]\n";
cout << "|" << setw(20) << setfill('.') << sString << "|" << "\t << [Width:20][align:default][fill:.]\n";
cout << "|" << setw(20) << setfill('+') << sString << "|" << "\t << [Width:20][align:default][fill:+]\n";
cout << "|" << setw(20) << setfill('=') << sString << "|" << "\t << [Width:20][align:default][fill:=]\n";
Example 2: c++ write string
#include <iostream>
int main() {
std::cout << "Hello" << std::endl;
printf("hello");
}