1std::string str = "hello world";
2char *str = "hello world";
3char str[] = "hello world";
4char str[11] = "hello world";
1/*
2OUTPUT
3String value: Programming {where applicable: -31.05}
4-----------------------------------------------------------------------------
5|Programming| << [No manipulation]
6| Programming| << [Width:20][align:string_default=right]
7| Programming| << [Width:20][align:right]
8|Programming | << [Width:20][align:left]
9|-31.05 | << [Width:20][align:int_default=left]
10|- 31.05| << [Width:20][align:internal]
11|.........Programming| << [Width:20][align:default][fill:.]
12|+++++++++Programming| << [Width:20][align:default][fill:+]
13|=========Programming| << [Width:20][align:default][fill:=]
14-----------------------------------------------------------------------------
15*/
16
17string sString = "Programming"; // Length = 11
18//NOTE: always place the settings before the actual string in cout
19
20// width
21cout << "|" << sString << "|" << "\t\t << [No manipulation]" << endl;
22cout << "|" << setw(20) << sString << "|" << "\t << [Width:20][align:string_default=right]\n";
23
24// alignment
25cout << "|" << setw(20) << right << sString << "|" << "\t << [Width:20][align:right]\n";
26cout << "|" << setw(20) << left << sString << "|" << "\t << [Width:20][align:left]\n";
27cout << "|" << setw(20) << -31.05 << "|" << "\t << [Width:20][align:int_default=left]\n";
28cout << "|" << setw(20) << internal << -31.05 << "|" << "\t << [Width:20][align:internal]\n";
29
30// fill (HAVE to use single quotes in the setfill argument definition)
31cout << "|" << setw(20) << setfill('.') << sString << "|" << "\t << [Width:20][align:default][fill:.]\n";
32cout << "|" << setw(20) << setfill('+') << sString << "|" << "\t << [Width:20][align:default][fill:+]\n";
33cout << "|" << setw(20) << setfill('=') << sString << "|" << "\t << [Width:20][align:default][fill:=]\n";
1#include <iostream>
2
3int main() {
4 std::cout << "Hello" << std::endl; //endl = end line/new line
5 // or
6 printf("hello");
7
8}