Mail Archives: djgpp/1998/09/13/13:01:48
Hi,
I'm unsure who is to blaim for the following bug, but here it is:
---------------
#include <iostream.h> //Stream library
#include <conio.h> //Console i/o library
#include <stdio.h>
int x; //Horizontal position of star
int y; //Vertical position of star
void Init()
{
x=40;
y=12;
}
void Display()
{
gotoxy(x,y); //Move cursor (conio)
cout << "*"; //Display a star (iostream)
}
void Up()
{
y-=1; //Up one line
}
void Down()
{
y+=1; //Down one line
}
void Left()
{
x-=1; //Left one position
}
void Right()
{
x+=1; //Right one position
}
//Main program
void main()
{
setvbuf(stdout, NULL, _IONBF, 0);
Init();
Display(); //Display it on the screen
Up(); //Move it up
Display(); //Display it again
Up(); //Move it further up
Display(); //Display it again
return;
}
----------------
In the above example, the compiler complains "return;" is used in a
case where "main()" is non-void.. But as you can see, it IS declared
to return void! Anyway, I am using DJGPP 2.1 with GCC 2.8.1.. Try and
compile the code yourself. You will get the same results.. As for why
I am using "void main", I am not; this code was provided to me by my
teacher, so go blaim him <g> .. I know better ..
Gili
- Raw text -