Read a Compiled file of an RTU

This is a discussion on Read a Compiled file of an RTU within the C Programming forums, part of the General Programming Boards category; Hi All I have a compiled file of some of the RTUs in the filed, i need to copy that ...

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,454
    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...
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

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, 09:57 AM

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