Current status of iostream.h

T

Tim Cambrant

Hello, I'm relatively new to C, although I've touched the subject several
times for a couple of years. Tutorials etc. always taught me that I should
use (in the beginning at least) cin and cout when outputting text to the
screen.

Recently, when giving C another shot with the new GCC 3.3, I couldn't use
the functions defined in iostream.h anymore. I don't remember the actual
errors, but i think that the library had been separated into istream.h and
ostream.h. I seem to recall a warning as well, when using any of the
functions in those files.

Is iostream getting deprecated, or was I just using it wrong? I'm using GCC
2.95.4 at the moment, so I can't recreate the errors again for now. I do,
however, want to know if I should use iostream for file-io etc. or if
another library has taken it's place.

I like to be aware of how to do things the "right" way, and following
standards and so on, so a change of this caliber might as well catch my
radar now, so I won't have that problem the next time I'm confronted with a
newer GCC-version.

Any answers to this matter would be appreciated. Thank you.
 
S

Simon Biber

Tim Cambrant said:
Hello, I'm relatively new to C, although I've touched the subject
several times for a couple of years. Tutorials etc. always taught
me that I should use (in the beginning at least) cin and cout when
outputting text to the screen.

Then they are not teaching you C, but rather C++. If you intend to
learn C++ then you should be reading/posting to comp.lang.c++
instead.

There is no iostream.h in C. There is no cin nor cout in C. The <<
and >> operators only ever mean 'shift left' and 'shift right'.
 
T

Tim Cambrant

I think you are confuzing C++ with C. In C, the relevant cout/cin
counterparts are included in stdio.h.

Oh, of course I am... I've been down both roads, but never got anywhere, so
I'm not surprised I would be mixing them together.

You wouldn't have any idea of what is happening with the C++-library then,
would you? (Might be good to know anyway, if i ever deal with C++ again).
Thanks for the answer.
 
M

Martin Ambuhl

Tim said:
Hello, I'm relatively new to C, although I've touched the subject several
times for a couple of years. Tutorials etc. always taught me that I should
use (in the beginning at least) cin and cout when outputting text to the
screen.

The identifiers 'cin' and 'cout' have no defined meaning in C. They are in
the user's namespace and have no predefined relationship to input or output.

In the foul C++ language, these identifiers are defined in the 'std'
namespace, but without qualification are in the user's namespace and
unrelated to input or output, as in C.
Recently, when giving C another shot with the new GCC 3.3, I couldn't use
the functions defined in iostream.h anymore.

<iostream.h> is not a C or C++ header.
The C header is <stdio.h>.
The C++ headers are <iostream> and <cstream>.
 
T

Tim Cambrant

Martin Ambuhl said:
The identifiers 'cin' and 'cout' have no defined meaning in C. They are in
the user's namespace and have no predefined relationship to input or output.

In the foul C++ language, these identifiers are defined in the 'std'
namespace, but without qualification are in the user's namespace and
unrelated to input or output, as in C.


<iostream.h> is not a C or C++ header.
The C header is <stdio.h>.
The C++ headers are <iostream> and <cstream>.

That clarifies it all somewhat. Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top