Re: how to modify a txt file

From: Jacob Oost (zork_at_columbus.rr.com)
Date: 01/31/05


Date: Mon, 31 Jan 2005 03:44:53 GMT

Jerry wrote:
> Hi, everybody:
>
> I want to modify a portion of a txt file. The way I do it is to
> open the file in read mode, and create a new file, and delete the old
> file, and rename the new file.
> I am wondering if this is a common practice of modifying a file in
> C, is there any other way to do it?
> Thank you all for your attention.
>
>
> --Jerry
>

Couldn't you just open a new file for reading or writing?

fptr = fopen("filename", "r+");

Of course you'd do the standard error-checking. I'm new to this but
isn't that what you want? According to my book, "r+" opens an existing
file for reading or writing.

-- 
----- BEGIN GEEK CODE BLOCK -----
Version 3.1
GAT d? !s !a C++++ UL+ P L++ E- W+ N+ o-- K- w--
O- !M !V PS-- PE++ Y+ PGP- t++>++++* 5? !X-- R- tv b++ DI+ D++
G e !h !r !y
..... END GEEK CODE BLOCK ----


Relevant Pages

  • Re: who to use fwrite to write through a hidden file
    ... It opens a file, and NEGLECTS TO SEE IF THE OPEN WORKED! ... You have no reason to assume this could work. ... Let me put it this way: I would not consider writing such a piece of code. ... how can you be trusted to modify something as critical as ...
    (microsoft.public.vc.mfc)
  • Re: os.path.getsize() on Windows
    ... WRITING, not reading. ... That's why he has to specify when he opens it that he wants exclusive ...
    (comp.lang.python)
  • Re: Modifying a record field value while not blocking it to others
    ... as it is effective only when you go out of the related field you just ... And of course again the record you are trying to modify has not to be 'open' ... someone opens that ID=12 record everything in it is locked. ... so the developer has to create their own work-around. ...
    (comp.databases.filemaker)
  • Re: Modifying a record field value while not blocking it to others
    ... And of course again the record you are trying to modify has not to be 'open' ... someone opens that ID=12 record everything in it is locked. ... often add a script line which opens a random record if the file holds enough ... system where customers use Credits when renting items and get Credits ...
    (comp.databases.filemaker)
  • Re: Stylesheet for My Sites
    ... customized thestylesheetfor the portal and WSS sites but don't see ... anywhere to modify the styles for all users "My Site". ... Opening a MySite in Internet Explorer opens that specific MySite in ... searching through the folder list in SharePoint ...
    (microsoft.public.sharepoint.portalserver)