scanf a value ignoring a previous one

This is a discussion on scanf a value ignoring a previous one within the C Programming forums, part of the General Programming Boards category; A very quick question. I need to scan and store the second value in a file but I am forgetting ...

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    28

    scanf a value ignoring a previous one

    A very quick question. I need to scan and store the second value in a file but I am forgetting the syntax of fscanf. Let me illustrate it with an example.

    A file has one line, the following:

    1, 2

    I want to parse the line and store the second value (2).
    It will be

    fscanf(fp, "what_I_am_asking, %d\n, &number);

    What is the syntax of what_I_am_asking to ignore the first value, cause I am forgetting it?

    Cheers.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,498
    Just what manual pages were invented for.
    "%*d,%d"

  3. #3
    Registered User
    Join Date
    Apr 2005
    Posts
    28
    Thanks a lot. Both for the answer and for reminding me the man pages.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 08-23-2008, 01:16 PM
  2. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  3. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. scanf - data is "put back" - screws up next scanf
    By voltson in forum C Programming
    Replies: 10
    Last Post: 10-14-2002, 04:34 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21