Well, you could review functions such as _Ropen() to open files, _Rreadn() to read next, and many related ones. These are documented in the C Runtime Library manual.
Or use SQL. That could be normal dynamic SQL or through SQL CLI. Coding to SQL CLI is essentially just like coding for ODBC.
Except maybe for some of the dynamic SQL, be prepared for a long and difficult project that will be error prone at best and potentially difficult to maintain as PTFs alter database features and upgrades change behaviors. It can certainly be done, but it’s likely to stay pretty limited in scope. Only basic functions — open, close, read and write — might be as good as it gets.
You probably need to work up a general statement of the business problem you’re needing to solve and ask for comments and suggestions on how to solve it.