Question:
What's the difference between an API and a library, such as iostream?
God of the Godless
2007-08-21 16:08:33 UTC
What's the difference between, say, the Windows API and a library or whatever they're called (a library, I think) such as iostream? (I'm programming in C++ by the way.) Thanks.
Three answers:
Del Piero 10
2007-08-21 16:19:16 UTC
A library is a series of ready built functions you can utilise, so rather that having to type in a load of commands every time you simply select the library function and fill in the parameters such as :



CreateWindow(SizeX,SizeY,Bordercolor, WindowColor)



An API Applications Programmer Interface) is a gateway in to a program or operating system. So if you had a terminal emulator program that loaded in two halves such as Terminal.exe (user interface) and kernel.exe (the kernel of the operational part of the program) when kernel.exe loaded you could talk to it via its API, usually via a software interrupt. Such as -



INT Kernel (Function number, parameter).
valerie
2016-05-19 06:30:52 UTC
An API stands for (application programming interface) An API is something that allows the user to user the functionality of a third party. Examples of API's could be DirectX and Opengl. These are Graphics API's and they allow you to use graphics to create games on your computer. So basically it gives the programming uses that the original language didn't have. Now let's move onto library. A library is a collection of all the things which are needed to use the API. With all these header files and .cpp files and .dll files and such. The API simply wouldn't work. It's like trying to make an Hello World program (using cout) in C++ without including the iostream It simply wouldn't work. So in order to use cout in C++ you would have to include the iostream (#include ) So without the library the API couldn't run. It needs those files in order to run the program. So to sum everything all up . API is the program itself. It allows the user to manipulate it's uses to go beyond what the language has to offer. Ex: C++ doesn't have built in graphics but with the help of directx and opengl and allegro and all the others. We can create games and cool looking software and what not. Now the library is what's needed in order to make the API work which includes all the .dll files and the header files (.h) and the c plus plus files (.cpp) and all that other stuff (depending on which programming language you're using) Hope This Helped :D
anonymous
2007-08-21 16:13:48 UTC
An API is an Application Programer's Interface. It's a collection of functions that access a library or a set of objects or a compiler or an OS. A library is also a set of functions, but one that adds functionality.



But in the real world, often the terms are used interchangeably.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...