Re: how to modify a txt file
From: Jacob Oost (zork_at_columbus.rr.com)
Date: 01/31/05
- Next message: infobahn: "Re: File handling"
- Previous message: Chathu: "File handling"
- In reply to: Jerry: "how to modify a txt file"
- Next in thread: Jerry: "Re: how to modify a txt file"
- Reply: Jerry: "Re: how to modify a txt file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 ----
- Next message: infobahn: "Re: File handling"
- Previous message: Chathu: "File handling"
- In reply to: Jerry: "how to modify a txt file"
- Next in thread: Jerry: "Re: how to modify a txt file"
- Reply: Jerry: "Re: how to modify a txt file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|