|
-
Jun 23rd, 2000, 04:48 AM
#1
Thread Starter
Member
I'm reading a book on C++ and it's using "cout" to print to the screen (i'm coming from vb of course)... but i've seen the statement "printf" to do the same thing. what's the difference between these?
-
Jun 23rd, 2000, 05:16 AM
#2
Addicted Member
Well, cout is the C++ way of console screen dumping. printf is the old ANSI C way of printing to the screen.
For console applications, stick with cout unless your learning C.
-
Jun 23rd, 2000, 05:45 PM
#3
Monday Morning Lunatic
cout is a defined member of an 'ostream', which are type safe at compile time, and you can define your own actions. They're also simpler:
Code:
printf("%s = %d\n", mychar, mynumber);
cout << mychar << " = " << mynumber << endl;
if you have your own class, then you can make it define something so that you can put it into the stream, and it will display as you want it to.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|