Re: Help: a correct c program can not be complied

From: Saroj Pattnaik (saroj.pattnayak_at_oracle.com)
Date: 07/15/04


Date: Thu, 15 Jul 2004 11:57:19 +0530

Functions you used are not availabele in MS studio header files.
conio.h and dos.h
You can use TC compilers to work it okay.
saroj

kim wrote:
> The c program is an example and should be correct.
>
> I tried to compile the c file with MS studio 6.0. But failed with the
> several err and warning messages. Does anyone know how to make it work?
> Thanks.
>
>
> Here is the c file:
> /*file name way.c*/
> #include <stdio.h>
> #include <conio.h>
> #include <dos.h>
> void put (int x,int y) {
> textcolor(CYAN);
> gotoxy(x,y);
> cprintf(".");
> sound(440);
> delay(3);
> nosound();
>
> }
>
> void snd (void){ // it was just an idea ;)
> sound(100);
> delay(2);
> nosound();
> }
>
> void main()
> {
> int x=1,y=2,ctr=0;
> _setcursortype(_NOCURSOR); //just for eye comfort ;)
> clrscr();
> gotoxy(1,1);
> textcolor(WHITE);
> cprintf("ESC to exit, use arrowkeys to control"); //directive
> window(1,2,80,25); // setting moving area
> put(x,y); // puting smiling face
> while(ctr!=1)
> switch(getch()){
> //you can use kbhit here but i wrote just ex.
> case 77: // write
> if(x>=1 && x<79){
> gotoxy(x,y);
> cprintf(" ");
> x++;
> }
> put(x,y);
> snd();
> break;
> case 75: // left
> if(x>1 && x<=80){
> gotoxy(x,y);
> cprintf(" ");
> x--;
> }
> put(x,y);
> snd();
> break;
> case 72: // up
> if(y<=25 && y>2){
> gotoxy(x,y);
> cprintf(" ");
> y--;
> }
> put(x,y);
> snd();
> break;
> case 80: // down
> if (y<24 && y>=2){
> gotoxy(x,y);
> cprintf(" ");
> y++;
> }
> put(x,y);
> snd();
> break;
> case 27: // quit
> ctr=1;
> break;
> }
> textcolor(7); //turn back to normal color
> return(0);
> }
>