Thread: Read a Compiled file of an RTU

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    34

    Read a Compiled file of an RTU

    Hi All
    I have a compiled file of some of the RTUs in the filed, i need to copy that file into a buffer and then used that buffer to move the file into the RTU. The file is about 50Kbyte (i Don't know the structure/formatting of the file). All i need is to copy that file into a buffer of type byte. What would be a fastest method of doing it? Do i have to use fgets function, but i guess it only brings the one line of file. The whole idea here is to think of that file as a chunk of bytes and then copy those bytes into a buffer?

    My skills for C are not that sharp, please help me out in order to accomplish this, i would really appreciate your time in this regards

    Thanks in Advance!

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,794
    open file as binary using "rb" mode of fopen and then - fread to read big chunks

    you can even determine the file size using ftell and allocate the buffer to read the whole file at once - search for sample code on the forum - there is a lot...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  4. How to convert char read from file into string
    By cruxxe in forum C Programming
    Replies: 7
    Last Post: 05-22-2002, 02:09 PM
  5. Hmm....help me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 10:57 AM