This is a Bresenham algorithm for a line in the first positive octant. The code is almost from the http://www.cs.helsinki.fi/group/goa/mallinnus/lines/bresenh.html. but it doesnt work and the turbo c++ says there is an error in the line 4, ") EXPECTED". I really don't know how to solve it. I would be happy if there is any help.
#include <iostream.h>
#include <graphics.h>
#include <conio.h>
void LINE(int x1, int y1, int x2, int y2)
{
int dx = x2 - x1;
int dy = y2 - y1;
int y = y1;
int e = 0;
for (int x = x1; x <= x2; x++)
{
putpixel(x, y, color);
e += dy;
}
}
int main()
{
int x1, x2, y1, y2, color, gd = DETECT, gm;
initgraph(&gd, &gm, "..\\bgi");
cout << "\n Enter Start Point:";
cin >> x1 >> y1;
cout << "Enter End Point:";
cin >> x2 >> y2;
cout << "Enter your Favorite Color:";
cin >> color;
line(x1, y1, x2, y2, color);
getch();
closegraph();
return 0;
}