Search ray triangle intersection in google. Usually first you need to solve a plane x ray intersection, then you need to check whether the point is in the triangle or outside of it. There are numerous methods to do it and plenty of articles and code about it.
EDIT:
And here's what I would do:
Using analytical geometry, first I define a ray v = v0 + t*d, where v0 is the point in 3d where the ray starts, d is the directional vector of the ray and t>=0.
Let's assume that the triangle has vertices p0,p1,p2 we can get the normal by n = (p1-p0)x(p2-p0)
After that we can get a plane equation from this normal and the coordinate of one of the vertices:
Let's assume (ux,uy,uz) is a point on the plane defined by the normal n = (nx,ny,nz) and the point p0 = (p0x,p0y,p0z) then:
nx*(ux-p0x) + ny*(uy-p0y) + nz*(uz-p0z) = 0, or n*(u-p) = 0, where * is the dot product.
So by taking the ray equation and the plane equation we solve for t.
v = v0+ t*d
n*(u-p) = 0
if v is a point of the plane then:
n*(v0+t*d-p) = 0 => t = n*(p-v0)/(n*d) (remember to check for the cases where the ray lies in the plane = infinite number of solutions, or where the ray is parallel to the plane = no intersection)
And that's half the problem solved. Next you just decide whether the point with t = n*(p-v0)/(n*d) is inside the triangle or not (use barycentric coordinates, or you can do it with vector products).
P.S. I am pretty sure there was even an article on this on gamedev.net. Here it is: http://www.gamedev.net/page/resources/_/technical/math-and-physics/intersection-math-algorithms-learn-to-derive-r3033 , http://www.gamedev.net/page/resources/_/technical/math-and-physics/advanced-intersection-test-methods-r3536