You may have a look to shapelib (http://shapelib.maptools.org/) or gdal/ogr ( http://www.gdal.org/ ). Shapelib provides a C - API for vector GIS data, and GDAL/OGR a C++ library for both, raster and vector data, rsp., where, as far as I know, the OGR shapfile driver uses shapelib. Depends also on the input format of your raster files (e.g. ASCII grids are quite easy to read), type of classification and coordinate reference system (proj4 library can do conversions and transformations, if needed).
If you are not coding within your own programming projects, you may also consider GRASS or M4SW (see http://www.maptools.org/ ), which contains a couple of command line utilities that might do what you need.