Thread: Error!!!

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    11

    Red face Error!!!

    Hi, I'm trying to read a binary file and simply print out the numbers in hex...but it doesn't seem to be working!!! It doesn't seem to be printing anything at all!! PLEASE someone help!!

    #include <stdio.h>
    #include <stdlib.h>

    int main()
    {
    unsigned long code ;
    int num;
    int count = 0x00400000;
    FILE * input ;

    input = fopen("b3-long-sample.bin", "rb");

    while( fscanf( input,"%ld", &code) == 1)
    {
    printf(" %x %08lx\n", count, code);
    count +=4;
    }
    fclose(input);

    return 0;
    }

  2. #2
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511
    With binary files use fread and fwrite. This should help.

    Mr. C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM