i want to print a list of format like the following:
NO WORD COUNT
1 abc 1
2 abc 7
but as no, word, and count is variable, i can't ensure how long it is.
how can i print the format like that? i used "\t" to cout. but the format is still not like that, can anybody tell me how to do that format??
Hello if you are using the gcc-g++ compiler as in Linux then you could use the 'set field' option
from the header file iomanip(I/O manipluation). There are many other features in it you may use, but I
will show you the set field feature which I think will suit your program.
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
//
//use a field width of 20
//
cout << "Right justification:" << endl;
cout << "|" << setw(20) << "your data here" << "|" << endl;
cout << "Left justification: " << endl;
cout << "|" << setw(20) << left << "your data here" << "|" << endl;
//
// you can set the format fields to suit your data as in...
//
cout << setw(10) << right << "This" << endl << setw(10) << "is" << endl << setw(10) <<
"a" << endl << setw(10) << "column" << endl << setw(10) << "of" << endl <<
setw(10) << "words" << endl;