C++ gurus and learners, we program ourselves :P all work is CC licensed

Saturday, December 14

Use of ascii characters to print table in console


A post on using ascii chart for printing a table in console
#include <iostream>
using namespace std;

int main() {
 char topLeftCorner = (char)201, bottomLeft = (char)200, topRight= (char)187;
 char bottomRight = (char)188, horizontal = (char)205, vertical = (char)186;

 cout<<topLeftCorner;

 for(int i=0; i<10;i++)
  cout<<horizontal;

 cout<<topRight<<endl;

 cout<<vertical;

 for(int i=0;i<10;i++)cout<<' ';

 cout<<vertical;
 cout<<endl<<bottomLeft;

 for(int i=0; i<10;i++)
  cout<<horizontal;

 cout<<bottomRight;

 //or you can use ascii character 219 for all of the purposes, it is very easy to use
 return 0;
}

0 comments :

Post a Comment