the file problem

This is a discussion on the file problem within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I made a file of records.....each record consists of one integer field......now i wanna retrieve the value from the integer ...

  1. #1
    juandy
    Guest

    Angry the file problem

    I made a file of records.....each record consists of one integer field......now i wanna retrieve the value from the integer field......how to do that ? i used fscanf function but it doesn't work......the other fields are string value..


    while(fgets(code,6,handle)!=NULL)

    { fgets(name,22,handle);

    fgets(position,22,handle);

    fscanf("%d",&age); // this is the integer value

    printf("%s ",code);

    printf("%s ",name);

    printf("%s ",position);

    printf("%-3d\n",age);

    }

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,138
    >i used fscanf function but it doesn't work......

    Maybe it went on strike... try to pay more money...

    Seriously, it will do something. What happens
    when you run it ? What does it print ?
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    juandy
    Guest
    I have corrected it.....the problem was i forgot to put the file stream pointer in the fscanf function......btw...thank's for your kindness.....

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,138
    oh... damn, you're right, I didn't even notice... whoops
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  5. #5
    juandy
    Guest
    I have corrected it.....the problem was i forgot to put the file stream pointer in the fscanf function......btw...thank's for your kindness.....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie homework help
    By fossage in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 04:27 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 04:02 AM
  3. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  4. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  5. Rename file problem
    By Emporio in forum C Programming
    Replies: 2
    Last Post: 06-05-2002, 09:36 AM

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