Thread: Reading an unsigned long from a file

  1. #1
    Unregistered
    Guest

    Angry Reading an unsigned long from a file

    How come:-

    unsigned long lFrames;
    FILE *fp;

    fp = fopen("data.dat", "rb");
    fread(&lFrames, sizeof(unsigned long), 1, fp);
    fclose(fp);

    Doesn't work?

  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    It works for me. Are you sure the number is stored as an unsigned long in the file and not a character. If the number is stored as characters, your code will read sizeof(long) characters from the file which will not be what your looking for.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Heap corruption using zlib inflate
    By The Wazaa in forum C++ Programming
    Replies: 0
    Last Post: 03-29-2007, 12:43 PM
  2. Replies: 16
    Last Post: 10-29-2006, 04:04 AM
  3. How do i un-SHA1 hash something..
    By willc0de4food in forum C Programming
    Replies: 4
    Last Post: 09-14-2005, 05:59 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. HUGE fps jump
    By DavidP in forum Game Programming
    Replies: 23
    Last Post: 07-01-2004, 10:36 AM
Website Security Test