hello there!
im creating a program with both stdio.h and iostream.h in the include header.
Can the program run with them both? or others?

Recommended Answers

All 9 Replies

If you are uisng VC++ 2005 or 2008 then you can't use iostream.h at all. That file is obsolete and has been replace with <iostream>

And yes, you can have stdio.h and <iostream> both in the same program.

thanks

for the predefined streams, it's safe to mix C stdio and C++ iostreams. you can safely use stdin and std::cin in the same program; the C++ Standard guarantees that it will work the way you would expect it to.

if you don't need to mix C stdio and C++ iostreams on the same stream, you can get better performance by turning this feature off std::ios_base::sync_with_stdio(false); however, if you need to open a file with C++ iostreams, and at the same time access that file as a C FILE*, there's nothing in the C++ standard to support that usage by default. however, the library is extensible, and a std::streambuf derived class that supports this is just a couple of dozen lines of code.

commented: Nice answer. +21

Yes they can.

Why would you need stdio.h in C++ ?

i always start with stdio.h in my programs (im a newbie),
but now im trying to explore other header files like
iostream.h and im starting there...:)

i always start with stdio.h in my programs (im a newbie),
but now im trying to explore other header files like
iostream.h and im starting there...:)

Forget iostream.h -- use <iostream> (without the .h extension)

hello there!
im creating a program with both stdio.h and iostream.h in the include header.
Can the program run with them both? or others?

As Ancient Dragon mentioned: change <iostream.h> to <iostream>. If this doesn't work on your compiler (probably Turbo...), you need to update your compiler to a modern one. Visual Studio (c++) 2008 free for example.

Here's a nice thread with some explanation about headers and also a list of which header are c/c++ standard and what they do.

you can use both h.files, but what kind of need arise for both ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.