Quantcast
Channel: Comments on: 13.7 — Random file I/O
Browsing index pages (28 articles)
↧

By: Alex

Generally, adding anything to or removing anything from a file directly is a bad idea. You’re better off reading the contents of the file into memory, modifying them in memory, and then writing them out.

View Article


By: Kausthub

Hi Alex You haven’t taught how to delete a record in a file having classes or structures

View Article


By: LeoNardo

hii I ‘m confusing about How to modify the content in file by random access

View Article

By: Alex

The best way to do this is either to: 1) Read the contents of the file into memory, modify the content in memory, and write them back out, or 2) While you’re reading the contents of the file, write...

View Article

By: RWDavid

Hi Alex 🙂 Is there anyway to write into a file where it does not overwrite the existing characters? For example, you search for every vowel in the text file and you want to insert a ‘$’ after the...

View Article


By: Alex

I don’t actually know. It must have something to do with the way the streams are implemented, but I don’t have enough in depth knowledge on that topic to say.

View Article

By: Alex

It’s generally a bad idea to try to add/delete content from the middle of a file. For this kind of thing, it’s easier to either: 1) Read the whole file into memory, skipping the content you want to...

View Article

By: Sameeha Basha

Hi, Why is it necessary to do a seek operation in order to switch between read and write?

View Article


By: Hannah

Hi, is it possible to delete the contents of a file between locations A and B? I’m assuming that would be more difficult than overwriting, because we’re changing the location of the remaining content?

View Article


By: Alex

Typos fixed. It looks like some compilers have a buggy implementation of seekg() and tellg() when used in text mode. I’ve added a note about trying binary mode in this case.

View Article

By: Kodnot

First of all, a few minor typos: 1. Before the first big example: should be "Here’s" instead of "Heres"; 2. In "Reading and writing a file at the same time using fstream": "…and changes the any vowels...

View Article

By: Alex

Fixed, thanks!

View Article

By: Lokesh

#typo "One other bit of trickiness: Unlike istream," -> ifstream

View Article


By: Alex

To read a single line, use getline(). For what you want to do, I don’t think you need to seek by line. Just parse the entire database file upon load (using getline()), make your modifications to it in...

View Article

By: Aaron

What do I do if I want to read/write a single line? Is there a way to seek by line, rather than by bytes? I want to write a database file that contains variable length entries, reads them into an array...

View Article


By: Alex

Fixed. Thanks!

View Article

By: Matt

Typo ("it’s" should be "its"): * "- that is, skip around to various points in the file to read it’s contents." * "We’re going to write a program that opens a file, reads it’s contents, and changes the...

View Article


By: Grant

I think you can also use: iofile.seekg( iofile.tellg(), ios::beg); Grant

View Article

By: loift

I need to do many manipulations on a file on a bit level. Is there a better way to do this than: (1)open the file in input mode (2)open a second file in output mode (3)read the input file as a string...

View Article

By: paras

hi..I want to find whether a string is present or not in a file which i have already written and its contents are being displayed…can someone help me with the code…

View Article
Browsing index pages (28 articles)


Latest Images