# Grapics problem in c

Closed
nahida - May 6, 2012 at 12:48 AM
seo610 Posts 596 Registration date Monday February 8, 2010 Status Member Last seen June 29, 2015 - Sep 20, 2012 at 03:54 PM
Hello,

i cannot run my c program which first generate some random numbers and then draws different geometric shapes accordingly like ellipse,circle,rectangle..etc.
plz help me.
i share my code below:

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<dos.h>
#include<stdlib.h>
int maxx,maxy;
int main()
{
FILE *www;
int vertex[8];
int gd,gm,i,t,c,s,x,y;
char ch;
gm=0;
gd=DETECT;
initgraph(&gd,&gm,"c:\\tc\\bgi");
maxx=getmaxx();
maxy=getmaxy();
setcolor(CYAN);
rectangle(0,0,maxx,maxy);
while(1)
{
if(kbhit()) break;
www=fopen("c:\\out.txt","w");
for(i=0;i<100;i++)
fprintf(www,"%d",random(32000));
fclose(www);
www=fopen("c:\\out.txt","r");
while(fscanf(www,"%d%d%d%d%d",&t,&c,&s,&x,&y)==5)
{
if(kbhit())goto xx;
t=t%5;
c=c%16;
s=s%100;
x=x%640;
y=y%480;
setcolor(c);
switch(t)
{
case 0:
circle(x,y,s);
break;
case 1:
rectangle(x-35+s,y-20+s,x+35+s,y+20+s);
break;
case 2:
ellipse(x,y,0,360,s+20,s);
break;
case 3:
bar3d(x-35-s,y-20-s,x+35+s,y+20+s,10,1);
break;
case 4:
vertex[0]=x-20-s;
vertex[1]=y+10+s;
vertex[2]=x+s;
vertex[3]=y-10-s;
vertex[4]=x+20+s+s+s;
vertex[5]=y+10+s;
vertex[6]=vertex[0];
vertex[7]=vertex[1];
drawpoly(4,vertex);
}
delay(50);
}
fclose(www);
}
xx:
return 0;
}

## 1 response

seo610 Posts 596 Registration date Monday February 8, 2010 Status Member Last seen June 29, 2015
Sep 20, 2012 at 03:54 PM
When I compile it, I get : 36: 'random' undeclared (first use this function).
So it is your 'random' function that cause the problem.
You just have to write on yourself.