Results 1 to 3 of 3

Thread: Simple, but I'm a beginner

  1. #1

    Thread Starter
    Member
    Join Date
    May 1999
    Location
    San Jose, CA, USA
    Posts
    43

    Question

    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?
    -_=Progrium=_-
    Progrium Software

    Using: VB 6 Pro

  2. #2
    Addicted Member
    Join Date
    Oct 1999
    Location
    Dallas,TX
    Posts
    170
    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.

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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
  •  



Click Here to Expand Forum to Full Width