I'm the expert and you're the beginner, remember, so maybe I have a clue what I'm asking...just a thought...
Fact is you have way more than three problems. Your syntax is all over the place.
You need to follow my first suggestion. Write a SMALL amount of code to start. Then
get that code working BEFORE you try to go onto anything new. I'm not going to reply again until you
show evidence of having done that because I'm bored with repeating myself, and you would solve this
problem a whole lot quicker if you listened to me. I know it feels like a retrograde step to throw all
this wonderful code away and start over, but it's not really.
Anyway while I'm here. I'll see what Visual Studio 2010 will do with the code. Get a syntax-highlighting
editor by the way, it will make your life a LOT easier, and ALWAYS ALWAYS ALWAYS strictly indent code.
points_to_line() has too many braces
closest_point() doesn't have enough
By the way always define a return type. The default is int. Return int if that's what you want, otherwise
return void, then it's clear what your intention is.
points_to_line() first argument is wrong. The correct syntax is TYPE<space>VARIABLE.
You have TYPE<dot>VARIABLE.
In distance(), p and q are defined as struct point *, i.e. pointer to struct point, but you're
trying to use local semantics (p.x instead of p->x).
In point_and_slope_to_line(), p is defined as struct point and you're trying to use array semantics
to access x and y, i.e. p[x] instead of p.x. Also I've no idea what p_c[X] is meant to mean. Do you
mean p_c.x? Don't forget C and C++ are case sensitive.
In closest_point, p_c is defined as point, not point*. Remember the difference between pass by copy and pass
by reference. This is pass by copy, so if your aim here is to modify the caller's p_c, you need to change
the definition to point* (and use pointer semantics to access the attributes, e.g. p_c->x.
In distance(), remember that TYPE FUNCTION_NAME(ARGS)<SEMI-COLON> is a function PROTOTYPE, not a function definition.
So
Code:
double distance(struct point *p, struct point *q);
{
Maybe closest_point is missing a brace because you haven't finished writing it yet. It handles vertical and horizontal lines,
but what about the rest?
distance() uses automatic semantics not pointer semantics for accessing point's x and y members, i.e. point.x instead of point->y.
ReadFile doesn't initialise nobst.
Code:
points_to_line(s,t,&l);
underscores, letters O and digits 0.
Code:
points_to_line(_OO,_O0,&_0O);
ncircles is undefined.
c[i].c is undefined.
point_in_box is undefined.
SO. Abandon this lot, there are so many errors and things wrong with it that rescuing it is going to be harder work than my
approach. For the very last time, as a starting point you should write a program that reads the file and displays what it has found, with
relevant labels. This way you can be sure you've understood the data format. So the data you've given as an example might result
in the following output:
Driver drives from (0.0, 10.0) to (15.0, 0.0)
There are 4 blocks
Block 1 is at (2.0, 7.5) and has radius 1.75
Block 2 is at (3.0, 3.0) and has radius 1.0
Block 3 is at (7.0, 5.0) and has radius 2.0
Block 4 is at (12.0, 1.7) and has radius 1.5
Then consider putting the data into data structures. Use consistent naming, and use proper names not one letter characters. You're not programming
a 1K ZX81 you know, where 1-character variable names were pretty much essential. Then start adding BIT BY BIT, no more than 5-10 lines at a time,
new functionality. Use lots of printfs so the program displays everything it is doing and why, and you'll be able to debug it from the output.
Eventually when it's all written you can start removing the printfs so that it displays the required output only.


