--- In [email protected], Satya Prasad <[EMAIL PROTECTED]> wrote: > > I am trying (C program in unix) to insert data into > > text file while reading the file in "r+" mode. The > issue is that it overwrites the text file content > if data to be inserted is more than the length of > data read. > > Is there is a possible way to insert data in a text > file without overwriting data in the file?
Nope. Text files are text files, so you can write (without huge effort) only from beginning to end. What you would like to do is a so-called random-access; nothing to be done with text files. Random-access files are _usually_ handled by using open() and read() and write() or fopen(..., "rb+") and the like. Implementing random access on text files requires huge buffering efforts. Regards, Nico
