Measuring frequency of line segment intersection with triangles

I have a data set of 3D line segments centered at the origin, and a “sphere” with a surface made up of really small triangles, and need to write a program to measure the frequency of intersections of these line segments with the different triangles (the line segments always intersect with the sphere somewhere; the problem is figuring out where). I'm new to programming and am starting with C, so if anyone could give some idea of how to start, it'd be very much appreciated.