Redirecting Standard Input And Output : cout manipulator « Console « C++






Redirecting Standard Input And Output

Redirecting Standard Input And Output
 

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
   string line;
   int number = 0;
   while( getline( cin, line))
   {                             
     cout << setw(5) << ++number << ": "
          << line << endl;
   }
   return 0;
} 


           
         
  








Related examples in the same category

1.Show time and date.Show time and date.
2.Turn on hex output with uppercase X.Turn on hex output with uppercase X.
3.Skip 10 characters.Skip 10 characters.
4.Set cout format: ios::showposSet cout format: ios::showpos
5.Set cout format: ios::showpoint | ios::uppercase | ios::scientificSet cout format: ios::showpoint | ios::uppercase | ios::scientific
6.Predefine format for coutPredefine format for cout
7.Utility function for cinUtility function for cin
8.Define function to set coutDefine function to set cout
9.bell manipulator (using escape sequence \a)
10.ret manipulator (using escape sequence \r)
11.tab manipulator (using escape sequence \t)
12.endLine manipulator (using escape sequence \n and the flush member function)