While working on an assignment I am asked to implement several APIs. I am wondering what this means, as they are described as functions. What steps should I take to write an API, and how would this effect my actual program?
Printable View
While working on an assignment I am asked to implement several APIs. I am wondering what this means, as they are described as functions. What steps should I take to write an API, and how would this effect my actual program?
Basically, you're supposed to create a library of functions with some common theme.
For example, a graphics library would have circle, line, colour functions.
The group of functions you provide form an API.
Alright, that seems to make sense. If I then wanted to call that set of functions, I'd need to have them in some .h file? Thanks for your help.
Yes. You need .h's available as #includes for users of the API.
As Salem implies, an API generally belongs to a library. I think the simplest definition of a library WRT to C is that it is an executable object compiled from source without a main(), with the intention that it be linked to (used by) another executable object that does have a main() (and so is a full fledged "application").
So you write the library, and the API is basically the list of functions, types, etc. available to anyone who wants to write an application using that library. For example, the C API is all the functions, types, etc that are part of the standard C library.
Alright, I think I have a good grip on what an API is and how to use/implement it, thanks again for both of your help.