Computer problems,Computer help
*AX SOFT>>>Programming & Design

Hai guys i'm doing a project in C++.i want to know how to update the contents of a file in c++.?


Hai guys i'm doing a project in C++.i want to know how to update the contents of a file in c++.?

If you mean updating the data that is already in the file (for instance, changing a word in the file to another word), then you'll need to open the file for reading, read the whole file into a string (or several), parse the data, edit the data, and then write it back to the file. Essentially, this is what games and applications do for INI files and such.

If you just mean updating as in adding new data to the end, then just using the append flag when opening your fstream.

I am not positive, but if you are talking about a flat - or "text" file - I don't know of any easy way to actually 'update' the contents of it. Typically, in situations such as these, the file is simply overwritten with the new, modified file.
Unless there is some specific reason for which you need to actually modify the contents (e.g. for a class assignment or something), I would suggest simply overwriting the old file with the new, updated one.

Good luck : )

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • How to smooth this 3ds max model?!?

    Usually you get the best results from NURMS ("non-unified rational meshsmooth") Apply the Meshsmooth modifier and under 'method' choose 'NURMS'. You can increase the...

  • Anyone know anything about this company?

    Not much to do with programming :S

    ...
  • What is the purpose of the val( ) function in visual basic?

    a. Fo-rizzle

    ...
  • Alternative dedicated server to godaddy please?

    i personally use 3ix this company is awesome and i have never had any problems with them. for 拢50 a year you can get 500 gigabytes webspace,99 uptime,unlimited bandwith,unlimited mysql databases...

  • What are the types of Assembly Language? Give the sample of each.?

    Assembly languages are usually specified by the CPU that runs them, so some examples are: 8080, 8086, 6502, Z80, 8051, 68K, and so on. Different vendors use different "styles" for the...

  • Does anyone know a good excercise to do in JAVA?

    Check the following tutorial by Dana Nouri. That's a 5 part tutorial. ...

  • What is the Excel formula for this?

    B1: =(100*1.03) B2: =(B1*1.03) B3: =(B2*1.03) etc,

    ...
  • Table formatting?

    Use <PRE> with tables initially aligned in Courier New font. <PRE> Table </PRE>

    ...
  •  

    Categories--Copyright/IP Policy--Contact Webmaster