The key to understanding how to do this is that DB2 tables are AS/400 files. (Actually, they’re members of AS/400 files, but generally there is only one member in the file.) So, to access these tables, you open the file, define records as you usually define records in RPG or structures in C/C++, use record read/write/seek/delete calls (all starting with _R, such as _Rreadk, et cetera), and close the file at the end.
Note that there will be a separate vector of null flags if the file allows, and that VARCHAR fields are stored as a 16-bit integer, followed by a fixed-length number of characters.
The APIs would likely be the Call Level Interface (CLI) APIs. In other environments, these would probably be called “ODBC”.