Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Feb 2003
    Location
    East Side/West Side
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts

    scanf() Function in ANSI C

    Hello,

    I started programming in ANSI C on Christmas 2002. I was going through a book that I had gotten for Xmas, and the book didn't really explain the scanf() function too well (at least, what I got out of it didn't seem right). I was wondering if someone would be so kind as to 'splain it to me

    my MSN is phantasmagoria@l33ad.com

  • #2
    New Coder
    Join Date
    Jan 2003
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i dont know if ansi c is the same with c++, but if it is the same well an example would be:
    a=b+c;
    scanf("%d",&a);

    wherein a is the sum of whatever values that b and c holds? the &a points to the value contain within the address of a. scanf accepts data only of decimal type to the address of a.

  • #3
    New Coder
    Join Date
    Dec 2002
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    scanf work similar to printf... first you specify the format string, then the variables that you want to read in to..

    ex: scanf("%d %f %c", &anInteger, &aFloat, %aChar)

    (i can't remember if there needs to be commas between the &d, &f, and &c)

    Cheers,
    Dan

  • #4
    Regular Coder
    Join Date
    Feb 2003
    Location
    East Side/West Side
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I understand now

    And no, no need for commas


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •