[comp.lang.c++] C file functions in C++

cs161fch@sdcc10.ucsd.edu (Strange Attractor) (01/13/91)

I've just learned basic C++ in a class at school.  I'm now going
through a C++ book to learn the other features.  I have 2 questions.

[1] Does <stream.h> have a scanf() like it has a printf as
    cout<<form()?  If not, will there be one in an upcoming upgrade?
[2] C has fopen (filename,"r+") and other "+" options that allow both
    reading and writing.  Can you do this in <stream.h>?

Thanks,
whatis@ucsd.edu

jbuck@galileo.berkeley.edu (Joe Buck) (01/13/91)

In article <15556@sdcc6.ucsd.edu> cs161fch@sdcc10.ucsd.edu (Strange Attractor) writes:
>I've just learned basic C++ in a class at school.  I'm now going
>through a C++ book to learn the other features.  I have 2 questions.
>
>[1] Does <stream.h> have a scanf() like it has a printf as
>    cout<<form()?  If not, will there be one in an upcoming upgrade?

What is available in <stream.h> is very vendor-dependent.  There is no
standard.

>[2] C has fopen (filename,"r+") and other "+" options that allow both
>    reading and writing.  Can you do this in <stream.h>?

You can call any C function from C++, including fopen and scanf.
Just say

#include <stdio.h>

in some environments you may have to say

extern "C" {
#include <stdio.h>
}

--
--
Joe Buck
jbuck@galileo.berkeley.edu	 {uunet,ucbvax}!galileo.berkeley.edu!jbuck