Hi. Im a newb programmer. I m wondering...

1.what exactly is an api. I cant seen to find a clear answer
2. How do i use them in c++

There are many different kinds of api's (application program interface), which is probably why you can't find a clear difinitive answer because there isn't one. An API is just a term used for a set of libraries that some one or some company has written that programmers can use in their programs. For example Microsoft developed the win32 api so that programmers can create MS-Windows console and GUI programs. Another example is game engines such as DirectX and OpenGL.

How to use them: first you have to study the documentation that the author has (hopefully) written. That will tell you what functions are available and how to call them. Again you won't get a difinitive answer because there isn't one.

I use them as follows:

  1. Discover that I have a need for some programming service
  2. Look online for a library(*) that seems to offer the service
  3. Look for user commentary comparing some top contenders, or commenting on one or another
  4. Read the documentation enough to possibly confirm or actually deny whether this one will do the job I need done
  5. (deal with company policy about 3rd party libraries)
  6. (install it)
  7. Do some of the exercises, probably extending or modifying the ones that seem useful to my need
  8. Design my project
  9. Write some test cases
  10. Try to write my code to match the tests
  11. Loop back to step 8 as needed
  12. Run the tests
  13. Loop back to step 10 as needed
  14. Until done

* "library" is being used as a generic term for a programming service. Not all services are shipped (or made available) as libraries.

I have been wondering the same thing. how does one get these api's. are they header files or something.

One gets them by (purchasing and) downloading or receiving media. Most "free" C++ libraries arrive as source code which has a README file associated. That file tells you what to do to make the library and install the headers. Boost is well known and respected. Here's one of many places to find a list of stuff: http://www.thefreecountry.com/sourcecode/cpp.shtml. Beware that your OS may matter for some of these libraries.

Remember: You are not the first person to go looking for what you need, so you will find the better known of these libraries by searching on the web.

okay so is it a source code file that you call functions from, or a header file or something?

so, they can be either

It all depends on how the author decides to distribute it. Many provide free source code while others, like Microsoft, generally distribute only the binary libraries and header files. Some APIs you may have to purchase while others are free.

So why don't they just call it a Library? Why the new name?
Or Class?

Every (class) library has-a API (Application Programming Interface) that is the set of accessible constants, macros, functions, (classes and their accessible parts). You think about the API when you are using the library. Every API (can be) is implemented as some collection of files such as headers, object files, (shared) libraries or whatever. You think about the way the library is implemented when you are programming the library itself. Most of us don't clearly distinguish between a "Library" and it's "API" because the context disambiguates for us, but we all understand the difference when we need to.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.