Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

iostream / iostream.h ????

2 views
Skip to first unread message

spatch

unread,
Mar 10, 2001, 6:57:06 AM3/10/01
to
Can any one help me with this small problem.

I'm using the string and the iostream header file. When I tried to use the
iostream.h the cout command would not compile but the iostream does. Why is
this? What is the difference between iostream and iostream.h???

Also I am using ms visual C++ and have found for the string command to work
I have to use the line
'using workspace std;'

What does this line actually do, except from getting the program to
compiled.

Many thanks


al (Alex Gibson) .

unread,
Mar 10, 2001, 8:04:35 AM3/10/01
to

"spatch" <n...@email.com> wrote in message
news:qGoq6.9826$t1.8...@news6-win.server.ntlworld.com...
: Can any one help me with this small problem.

iostream is the correct header
iostream.h is a depreciated header for compatabilty with older compilers

that should be
using namespace std;

also header for string in c++
is
#include <string>

to use c style strings
#include <cstring>

more information
http://www.comeaucomputing.com/techtalk/#cname

from the welcome to comp.lang.c++
http://members.nbci.com/jshiva/welcome.txt

++Include the smallest, complete and compilable program that exhibits your
problem. As a rule, posters in comp.lang.c++ will not do homework, but
will
give helpful hints if you have shown some willingness to try a
solution.Take
a look at http://members.xoom.com/jshiva/hw.txt

Alex

http://www.faqs.org/faqs/C-faq/learn/ alt.comp.lang.learn.c-c++
http://www.eskimo.com/~scs/C-faq/top.html comp.lang.c
http://marshall-cline.home.att.net/cpp-faq-lite/ comp.lang.c++
http://members.xoom.com/jshiva/welcome.txt

http://www.geocities.com/alxx9672/learnc.html al's c and c++ links page


Dim Witt

unread,
Mar 10, 2001, 9:30:22 AM3/10/01
to

al (Alex Gibson) . <alxxN...@tig.com.au.remove.spamsux.die.spammer.die>
wrote in message news:98d8kf$gm6$1...@bugstomper.ihug.com.au...

>
> "spatch" <n...@email.com> wrote in message
> news:qGoq6.9826$t1.8...@news6-win.server.ntlworld.com...
> : Can any one help me with this small problem.
> :
> : I'm using the string and the iostream header file. When I tried to
> : use the iostream.h the cout command would not compile but the
> : iostream does. Why is this? What is the difference between
> : iostream and iostream.h???
> :
> : Also I am using ms visual C++ and have found for the string command
> : to work I have to use the line
> : 'using workspace std;'
> :
> : What does this line actually do, except from getting the program to
> : compiled.
> :
> : Many thanks
>
> iostream is the correct header
> iostream.h is a depreciated header for compatabilty with older compilers

If you mean deprecated, rather than depreciated, then that's incorrect for
<iostream.h>. The standard does include a number of deprecated headers but
<iostream.h> is not one of them. You're correct, of course, about many
compilers including <iostream.h> for compatibility with existing code.

Dim

Dim Witt

unread,
Mar 10, 2001, 9:56:06 AM3/10/01
to

spatch <n...@email.com> wrote in message
news:qGoq6.9826$t1.8...@news6-win.server.ntlworld.com...
> Can any one help me with this small problem.
>
> I'm using the string and the iostream header file. When I tried to use
> the iostream.h the cout command would not compile but the iostream
> does. Why is this? What is the difference between iostream and
> iostream.h???

<iostream.h> is an older, non-standard, version of the <iostream> header. In
fact, because it's not part of the C++ standard there may be many versions
of <iostream.h>, all similar but potentially different which is a
portability issue.

<iostream> is the C++ standard header. Assuming that your compiler has this
header, and all recent compilers should have, you should prefer its use
over <iostream.h> unless you specifically need <iostream.h> for
compatilibity with existing code.

By the way, there are no 'commands' in C++.

> Also I am using ms visual C++ and have found for the string command
> to work I have to use the line
> 'using workspace std;'
>
> What does this line actually do, except from getting the program to
> compiled.

You'll find that such things as cout and string from the standard library
are in namespace std. In order to use them you will have to include the
appropriate headers and also qualify their use with the std:: prefix, e.g.:

std::cout << "Hello, World" << std::endl;

An alternative to this would be to use a using declaration, e.g.:

using std::cout;

This avoids having to use the std:: prefix whenever you use cout.

A further option is to use a using directive, e.g.:

using namespace std;

In doing this you are making all of the contents of namespace std available
without qualification.

Dim

Greg Comeau

unread,
Mar 10, 2001, 10:11:28 AM3/10/01
to
In article <98ddn0$o9h$1...@newsg1.svr.pol.co.uk>,

Dim Witt <dim...@bigfoot.com> wrote:
>al (Alex Gibson) . <alxxN...@tig.com.au.remove.spamsux.die.spammer.die>
>wrote in message news:98d8kf$gm6$1...@bugstomper.ihug.com.au...
>> "spatch" <n...@email.com> wrote in message
>> news:qGoq6.9826$t1.8...@news6-win.server.ntlworld.com...
>> : What is the difference between iostream and iostream.h???

>> : Also I am using ms visual C++ and have found for the string command
>> : to work I have to use the line
>> : 'using workspace std;'
>> :
>> : What does this line actually do, except from getting the program to
>> : compiled.
>>
>> iostream is the correct header
>> iostream.h is a depreciated header for compatabilty with older compilers
>
>If you mean deprecated, rather than depreciated, then that's incorrect for
><iostream.h>. The standard does include a number of deprecated headers but
><iostream.h> is not one of them. You're correct, of course, about many
>compilers including <iostream.h> for compatibility with existing code.

Well, one could validly argue that <iostream.h> was implicitly deprecated,
but yes, you're right, C's name.h are explicitly deprecated by
Standard C++ in favor of <Cname> headers. To the OP: some more
info can be found at

http://www.comeaucomputing.com/techtalk/#cname

As to the full breath and width of what 'using namespace std;' does
(note namespace not workspace), you really need a good C++ text
that discussed not only the syntax but the conceptual premise of
namespaces. For that, you might want to check out

http://www.comeaucomputing.com/booklist
--
Greg Comeau Comeau C/C++ 4.2.45 "so close"
ONLINE COMPILER ==> http://www.comeaucomputing.com/tryitout
4.2.45.2 during March! NEW ONLINE: Try out our C99 mode!
com...@comeaucomputing.com http://www.comeaucomputing.com

Dim Witt

unread,
Mar 10, 2001, 11:06:55 AM3/10/01
to

Greg Comeau <com...@panix.com> wrote in message
news:98dg70$g2k$1...@panix3.panix.com...

> In article <98ddn0$o9h$1...@newsg1.svr.pol.co.uk>,
> Dim Witt <dim...@bigfoot.com> wrote:
> >al (Alex Gibson) . <alxxN...@tig.com.au.remove.spamsux.die.spammer.die>
> >wrote in message news:98d8kf$gm6$1...@bugstomper.ihug.com.au...
> >> "spatch" <n...@email.com> wrote in message
> >> news:qGoq6.9826$t1.8...@news6-win.server.ntlworld.com...
> >> : What is the difference between iostream and iostream.h???
> >> : Also I am using ms visual C++ and have found for the string command
> >> : to work I have to use the line
> >> : 'using workspace std;'
> >> :
> >> : What does this line actually do, except from getting the program to
> >> : compiled.
> >>
> >> iostream is the correct header
> >> iostream.h is a depreciated header for compatabilty with older
> >>compilers
> >
> >If you mean deprecated, rather than depreciated, then that's incorrect
> >for <iostream.h>. The standard does include a number of deprecated
> >headers but <iostream.h> is not one of them. You're correct, of course,
> >about many compilers including <iostream.h> for compatibility with
> >existing code.
>
> Well, one could validly argue that <iostream.h> was implicitly deprecated,
> but yes, you're right, C's name.h are explicitly deprecated by
> Standard C++ in favor of <Cname> headers.

One might validly argue that the explicitly deprecated headers are
'normative for the current issue of the standard' whilst <iostream.h> is
not. I personally wouldn't use the term 'implicitly deprecated' for such a
header for that reason.

Dim

Greg Comeau

unread,
Mar 10, 2001, 2:27:04 PM3/10/01
to
In article <98djc1$bie$1...@newsg4.svr.pol.co.uk>,

I absolutely agree that one could argue that.

>I personally wouldn't use the term 'implicitly deprecated' for such a
>header for that reason.

I didn't say it was normatively implicitly deprecated, all I said
was that one could _argue_ that there are implicit deprecations too.
The thing is that there has only been one Standard C++,
so explicitly deprecating features tends to have a oxymoron'ish flavor
since it begs the question "Deprecated compares to what?"

Anyway, I agree that <iostream.h> is not part of Standard C++
and that whereas say <stdio.h> is, it is deprecated and
<cstdio> is the suggested alternative.

news:unix-pc.general

unread,
Mar 12, 2001, 3:40:13 AM3/12/01
to

Dim Witt <dim...@bigfoot.com> wrote in message
news:98ddn0$o9h$1...@newsg1.svr.pol.co.uk...
0 new messages