Sunday, 16 March 2014

How to BUILD text based Interactive Interface in C/C++

Why to use graphics when colored text can do the same thing.So here is a sample code in C/C++
to build a colorful text based UI for your project.



#include<iostream.h>
#include<fstream.h>
#include<conio.h>
#include<stdlib.h>
#include<ctype.h>
#include<stdio.h>
#include<string.h>

void main()
{

clrscr();
textcolor(14);
gotoxy(35,3);
cprintf("COMPILER - PASS 1");
gotoxy(37,6);
textcolor(4);
cprintf("INSTRUCTION !!");
textcolor(14);
gotoxy(37,7);
cprintf("--------------");
textcolor(14);
gotoxy(18,8);
int i=0;
//upper horzontal
for(i=0;i<50;i++)
{
cprintf("|");
}
int j,k;
//right vertical
for(j=0;j<10;j++)
  {
    gotoxy(68,8+j);
  cprintf("||");

  }
//bootom horizontal
gotoxy(18,18);
for(i=0;i<52;i++)
{
cprintf("|");
}
  j=0;
  for(j=0;j<10;j++)
  {
    gotoxy(18,8+j);
  cprintf("||");

  }
  gotoxy(22,10);
  textcolor(4);
  cprintf("HOWQUEST ");
     gotoxy(22,20);
     textcolor(14+128);
cprintf("-->");
  textcolor(4);
cprintf("Press Enter To Proceed");
 gotoxy(22,22);
     textcolor(14+128);
cprintf("-->");
  textcolor(4);
cprintf("Press E To Exit");

getch();

}

OUTPUT:




  • Graphics vary here.
  • Run the code then analyse


0 comments:

Post a Comment

Copyright @ 2013 HowQuest.

Join me on Facebook Follow me on Twitter Subscribe to RSS Email me Give it a title