What is the formula to find out if a third dot lies between two points?

I have (x,y) coordinates for positions A and B. I want to know if postion C is on

the same line that a and b are on.

I thought to use the formula y = mx + b to find the generic formula for the line for the known points A and B. After that plug in the x,y points for C in the line, and

if the line is still true, then line C is in part of the line. But, I do not know how

to do this mathematically. Any suggestions.

y

| .

| . B

| C

| .

|___A__________________x

calculate: (y2-y1)/(x2-x1) - that is the gradent of the line - call it 'm'

then for all points on the line: y=mx+c

so A(x1,y1) is on this line so: y1=m.x1+c so c=y1-(m*x1)

so now you have the equation of the line:

to check c(x3,y3) test: y3=m*x3+c

if it matches then it is on the line.