LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-30-2009, 11:42 PM   #1
vendtagain
Member
 
Registered: Sep 2009
Distribution: Slackware, Debian, Mac OS X, Zenwalk, Puppy, Gentoo
Posts: 199

Rep: Reputation: 32
difference between stdio.h and iostream.h?


i used to iostream for output with c++, but I have been noticing stdio.h more common for output since iv started linux? is stdio more for C and iostream made for c++? or is it just a preference?
 
Old 09-30-2009, 11:52 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

Quote:
Q: is stdio more for C?
A: Yes

Q: and iostream made for c++?
A: Yes

Q: or is it just a preference?
A: Yes
ALSO:
Using "printf()" in C++ is sometimes frowned upon...
... but you simply *can't* use "cout" in C.

'Hope that helps
 
Old 10-01-2009, 02:13 AM   #3
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by vendtagain View Post
i used to iostream for output with c++, but I have been noticing stdio.h more common for output since iv started linux? is stdio more for C and iostream made for c++? or is it just a preference?
It is not just a preference -- they refer to entirely different things:

Code:
# include <sdtio.h>

...

printf("There are %d bottles of beer on the wall\n",total);
Versus:

Code:
#include <oiostream>

...

std.cout << "There are " << total << " bottles of beer on the wall" << std.endl;
Completely different design and intention. By the way, in your programs don't mix the two I/O styles shown above -- use one or the other exclusively. Mixing them causes endless synchronization difficulties.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
stdio.c cigarstub Programming 12 12-19-2014 06:39 AM
a question about <iostream.h> tqviet Programming 5 07-26-2009 07:38 AM
Linux iostream vs Windows iostream davidguygc Programming 2 05-13-2007 09:13 PM
where is iostream invisibleghost Programming 2 10-24-2004 01:30 PM
iostream, or stdio? jpc82 Programming 7 11-05-2003 08:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration