Results 1 to 7 of 7

Thread: printf

  1. #1

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    Question printf

    i just came across the functions printf () and scanf ()...i didn't know what they were so i looked at them...after a bit i started really liking them compared to cout and cin.. is there a problem with me using those functions instead of cout and cin? (or a few other C functions as opposed to the ones in C++)?
    is it a bad thing? i thought that if i liked using these better then why not..
    anyways i just want to know what the experts have to tell me..

    thanks in advance

    Amon Ra
    Amon Ra
    The Power of Learning.

  2. #2
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Not a bad thing, but using printf() as opposed to cout might make the final .exe smaller
    Alcohol & calculus don't mix.
    Never drink & derive.

  3. #3

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500
    ok, so i think i will stick with them..
    thanks

    Amon Ra
    Amon Ra
    The Power of Learning.

  4. #4
    Hyperactive Member made_of_asp's Avatar
    Join Date
    Jul 2001
    Location
    123 Fake Street
    Posts
    394
    they do not have as much features as cout
    VS.NET 2003

    Need to email me?

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    You should use cout/cin in C++ programs, since printf and scanf are laughably non-type-safe.

    And also, you can't overload the % flags in printf to output your own objects, but you can in C++:
    Code:
    cout << myobject << endl;
    Trust me, use the streams.
    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

  6. #6
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    i like printf and scanf better because they're easier to use

    PHP Code:
    printf("you entered %s and %s\n"string1string);
    cout<<"you entered "<<string1<<" and "<<string2<<endl;

    scanf("%[a-z]", &cLetter);
    //im not sure how to input only letters using the streams 
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  7. #7
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Another thing, like parksie said, is cout is "type-safe", meaning you can basically print any variable without having to know its type (no %s, %d, etc.) or overload the << operator for your own classes.
    Alcohol & calculus don't mix.
    Never drink & derive.

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