Member Avatar for ak_2005

hi!

i tried to run the following program in BORLAND C++ version 5.02..

#include<stdio.h>
#include<graphics.h> 
#include<string.h> 
#include<math.h>
#include<conio.h>
int const monthcount=12,dataoffset=18;

struct indata
{
 float realarray[ 12]; 
 float array[ 12];
};

char getlabel[3];
indata data;
int monthplace[ 12];
float interval,chartbottom,radius; 

struct wcp
{
float x;
float y;
} coord[monthcount]; 

wcp center; 

int round(float a)
{
 int b;
 b=a; 
 if(a-b>0.5) 
  return ++b; 
 else
  return b;
}

void polyline(int x, wcp *y)
{
 for(int i=0;i<x-1 ;i++)
 line(y[i].x,y[i].y,y[i+1].x,y[i+1].y);
}

void getlab(int x)
{
 switch(x)
 {
  case 0:
  {
   strcpy(getlabel,"JAN"); 
   break;
  }
  case 1: 
  {
   strcpy(getlabel ,"FEB");
   break;
  }
  case 2:
  {  
   strcpy(getlabel," MAR"); 
   break;
  }
  case 3:
  {
   strcpy(getlabel,"APR"); 
   break;
  }
  case 4:
  { 
   strcpy(getlabel,"MAY"); 
   break;
  }
  case 5:
  {
   strcpy(getlabel,"JUN"); 
   break;
  }
  case 6:
  {
   strcpy(getlabel,"JUL");
   break;
  }
  case 7:
  {
   strcpy(getlabel,"AUG" ); 
   break;
  }
  case 8:
  { 
   strcpy(getlabel,"SEP"); 
   break;
  }
  case 9:
  {
   strcpy(getlabel,"OCT"); 
   break;
  }
  case 10:
  { 
   strcpy(getlabel,"NOV"); 
   break;
  }
  case 11:
  {
   strcpy(getlabel,"DEC"); 
   break;
  }
 }
}

void getdata()
{
 float t1=0.00,t2; 
 for(int t=0;t<12;t++)
 {
 getlab(t);
 printf("ENTER THE DATA FOR THE MONTH OF %s: ",getlabel);
 scanf("%f",&data.realarray[t]);
 if(data.realarray[t]>t1 )
 {
  t1=data.realarray[t];
 }
 }
 for(t=0;t<12;t++)
 {
  t2=data.realarray[t]/t1;
  data.array[t]=t2*400;
 }
}

void puttext(wcp textp)
{
 settextstyle(1,HORIZ_DIR,1);
 outtextxy(textp.x,textp.y,getlabel);
}

void drawlabels()
{
 wcp textposition;
 textposition.y=chartbottom;
 int zz=25;
 for(int az=0;az<12;az++)
 {
  textposition.x=zz;
  zz+=50;
  getlab(az);
  puttext(textposition);
 }
}

char valuep[5];

void findvaluep(int x)
{
 int y=x,ttt;
 char tg[5];
 strcpy(tg,"");
 do
 {
  ttt=y%10;
  switch(ttt)
  {
   case 0:
   {
    strcat(tg,"0");
    break;
   }
   case 1:
   {
    strcat(tg,"1");
    break;
   }
   case 2:
   {
    strcat(tg,"2");
    break;
   }
   case 3:
   {
    strcat(tg,"3");
    break;
   }
   case 4:
   {
    strcat(tg,"4");
    break;
   }
   case 5:
   {
    strcat(tg,"5");
    break;
   }
   case 6:
   {
    strcat(tg,"6");
    break;
   }
   case 7:
   {
    strcat(tg,"7");
    break;
   }
   case 8:
   {
    strcat(tg,"8");
    break;
   }
   case 9:
   {
    strcat(tg,"9");
    break;
   }
  }
  y/=10;
 } while(y>0);
 strcpy(valuep,"");
 for(y=0;y<strlen(tg);y++)
 {
  valuep[y]=tg[strlen(tg)-y-1];
 }
 valuep[y]=NULL;
}


void linechart()
{
 drawlabels();
 settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
 for(int t=0;t<monthcount;t++)
 {
  coord[t].x=monthplace[t];
  coord[t].y=450-data.array[t]-dataoffset;
  findvaluep(data.realarray[t]);
  outtextxy(coord[t].x,coord[t].y-10,valuep);
 }
 polyline(monthcount,coord);
}

void main()
{
 int gdriver=DETECT,gmode;
 initgraph(&gdriver,&gmode,"");
 getdata();
 cleardevice();
 chartbottom=450.0;
 interval=50.0;
 monthplace[0]=25;
 for(int z=1;z<monthcount;z++)
 monthplace[z]=monthplace[z-1 ]+interval;
 linechart();
 getch();
 cleardevice();
 closegraph();
}

but it tells me that BGI graphics is not supported under windows..
what does this mean????????

i tried googling it, but couldn't understand how to solve it, all i came to know is that there is some other header file to be used..

now what should i do?.. if i am to change the header file, then where to get the new header file from? and how to use this??

i am new to graphics programming in Borland c++, so i am not able to understand much... hence, if possible plz give me the exact procedure to follow..

plz help me out..

Which OS are you on and how were you trying to execute the program?

That error message seems pretty clear to me -- it means that your compiler can not compile that program because it contains code that is no longer supported. You will have to use an older Borland compiler, such as Turbo C.

BGI graphics was designed for earlier Borland compilers and won't work with 5.0+. So you have to rewrite the output portions of the program to remove the screen manipulation. Or you can find a graphics package you like and rewrite the output sections.

BGI graphics was designed for earlier Borland compilers and won't work with 5.0+. So you have to rewrite the output portions of the program to remove the screen manipulation. Or you can find a graphics package you like and rewrite the output sections.

there is a folder named BGI in the directory of Borland C++ 4.5 ,,,however i get the same problem "BGI graphics not supported under windows"--while compiling my project.....has it anything to do with my operating system ---i am using Windows Vista..??

You would be better served by starting a new thread as this one is over 2 years old :)

there is a folder named BGI in the directory of Borland C++ 4.5 ,,,however i get the same problem "BGI graphics not supported under windows"--while compiling my project.....has it anything to do with my operating system ---i am using Windows Vista..??

Yes. You are using a 15 year old compiler! That compiler doesnt support windows NT.

Borland C++ 4.52 - (1995) Official support for Windows 95, OWL 2.5

Borland C++ 5.0 - (1996, Windows 95) Released in March 1996. Works on Windows 95 and Windows NT 3.51. It does not (officially) work on Windows NT 4.0 (which was still in development at that time). 3rd party tests exhibited some problems on NT 4.0. It does not work in Windows 3.x or DOS. Despite that, it can produce either Win32, Win16 or DOS programs.

Borland C++ 5.02 - (1997) Final release of the Borland C++ IDE (subsequently replaced up by the C++Builder series), final release to support compilation to (real-mode) MS-DOS target. Windows NT 4.0 officially supported.

Member Avatar for ak_2005

BGI graphics was designed for earlier Borland compilers and won't work with 5.0+. So you have to rewrite the output portions of the program to remove the screen manipulation. Or you can find a graphics package you like and rewrite the output sections.

Yes. You are using a 15 year old compiler! That compiler doesnt support windows NT.

Hmmm... So BGI graphics is not meant for this version of the compiler.

I guess that pretty much clears the issue for me now.. though I abandoned my attempts looooooooooong time back...;)

and to the others who replied earlier, SO SORRY for not noticing your replies back then, I am not sure why I didn't check up on this thread at all. sorry again!!

if ur problm has been solved.. can u let me kno how u solvd it?

commented: Read the OP's last post (right above yours). They gave up forever ago. +0

I am a student. I install Turbo c++ 4.5 in my pc. But this does not have BGI folder

I am a student. I install Turbo c++ 4.5 in my pc. But this does not have BGI folder

Great :) You can't learn c++ with that ancient compiler. Get yourself a real compiler for modern operating systems such as Code::Blocks with MinGW or VC++ 2010 Express.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.