neuromancer
neuromancer

Reputation: 55559

#include iostream in C?

In C++ we always put the following at the top of the program

#include <iostream>

What about for C?

Upvotes: 20

Views: 111356

Answers (5)

Khaled Alshaya
Khaled Alshaya

Reputation: 96889

Well, this is called the standard I/O header. In C you have:

#include <stdio.h>

It's not an analog to <iostream>. There is no analog to iostream in C -- it lacks objects and types. If you're using C++, it's the analog to <cstdio>.

See also this fantastic question and its answer,

Upvotes: 36

Innocentboy
Innocentboy

Reputation:

In C :

#include<stdio.h> + #include<stdlib.h> to get the almost all functionality of <iostream>

For example there is system() function (for windows only) in <iostream> but not in <stdio.h>.

Upvotes: 2

Vivek
Vivek

Reputation: 473

#include <stdio.h>

C Standard Input and Output Library (cstdio, known as stdio.h in the C language). This library uses what are called streams to operate with physical devices such as keyboards, printers, terminals or with any other type of files supported by the system. Streams are an abstraction to interact with these in an uniform way; All streams have similar properties independently of the individual characteristics of the physical media they are associated with.

Streams are handled in the cstdio library as pointers to FILE objects. A pointer to a FILE object uniquely identifies a stream, and is used as a parameter in the operations involving that stream.

There also exist three standard streams: stdin, stdout and stderr, which are automatically created and opened for all programs using the library.

Upvotes: 3

Fred
Fred

Reputation: 4954

iostream is a C++ library for input-output. The C equivalent would be stdio.h

Upvotes: 5

danielv
danielv

Reputation: 383

#include <stdio.h> 

Upvotes: 5

Related Questions