Thread: Help- I'm new to this

  1. #16
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    The getchar() that is there now, is sucking in the newline character that was left from the scanf(). Do it again and you'll be coolio.
    Mainframe assembler programmer by trade. C coder when I can.

  2. #17
    Registered User LuizCPFL's Avatar
    Join Date
    Dec 2008
    Location
    Louisiana
    Posts
    20
    Can someone help me with DATA TYPES

    int = %d
    char = %s
    float = %f
    double = %?

    or is double and %f?!?!?

    and what's your technique to remembering them? Do you just know?
    Last edited by LuizCPFL; 12-08-2008 at 06:39 PM.

  3. #18
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    int = %d
    char = %c
    string = %s
    float = %f
    double = %lf
    hex = %x or %X
    pointer = %p

    Technique to remember? The same technique you learn your new girlfriend's name - you just do it right.
    Mainframe assembler programmer by trade. C coder when I can.

  4. #19
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    for printf, %f is both float and double. For scanf, %lf for double, %f for float.

    %s is for char[], %c for a single char.

    And yes, I know those, and %u, %x, %o, %p, %zu, %lld, %ld, %hd. Any others, I'll look up when I need them.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #20
    Registered User LuizCPFL's Avatar
    Join Date
    Dec 2008
    Location
    Louisiana
    Posts
    20
    Thank you I was looking for a list like that.
    I will make sure that I memorize it lol

  6. #21
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You may want to look at this one:
    http://www.cppreference.com/wiki/c/io/scanf
    and it's printf sibling, as it's got a more complete and accurate account of the standard variants.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #22
    Registered User LuizCPFL's Avatar
    Join Date
    Dec 2008
    Location
    Louisiana
    Posts
    20
    Quote Originally Posted by matsp View Post
    You may want to look at this one:
    http://www.cppreference.com/wiki/c/io/scanf
    and it's printf sibling, as it's got a more complete and accurate account of the standard variants.

    --
    Mats
    Wow thanks saving that site to favorites

Popular pages Recent additions subscribe to a feed