Appending and Extracting Data From Files


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Appending and Extracting Data From Files

  1. #1
    Atrops Guest

    Appending and Extracting Data From Files


    I need to be able to do two things in regards to files

    1) open a file append 2 bytes to it and than save it as a file w/ a different
    name.

    2) I need to be able to extract the last two bytes of the altered version
    of hte file I just created.

    I'm pretty unsure of how to do this. Can anyone point me in the right direction?


  2. #2
    Jack Guest

    Re: Appending and Extracting Data From Files


    "Atrops" <vsickle@mill.tds.net> wrote:
    >
    >I need to be able to do two things in regards to files
    >
    >1) open a file append 2 bytes to it and than save it as a file w/ a different
    >name.
    >
    >2) I need to be able to extract the last two bytes of the altered version
    >of hte file I just created.
    >
    >I'm pretty unsure of how to do this. Can anyone point me in the right direction?
    >


    The first step would be to go back and take the first semester class again.
    The one that covered this part of your homework. Either that or at least
    look at documentation on CFile or fstream before asking.

  3. #3
    Danny Kalev Guest

    Re: Appending and Extracting Data From Files



    Atrops wrote:
    >
    > I need to be able to do two things in regards to files
    >
    > 1) open a file append 2 bytes to it and than save it as a file w/ a different
    > name.


    depending on the library you intend to use, stdio or fstream, open the
    file in append mode and use fwrite or the insertion operator to write
    two bytes to it. The close the file.
    >
    > 2) I need to be able to extract the last two bytes of the altered version
    > of hte file I just created.

    open the file in read mode, move the file pointer to the end - 2 bytes,
    read the last two bytes and close it. I won't give complete code samples
    here because the code depends on the library you're using and you should
    be familiar with at least one of them.

    Danny

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center