0
Fseek() overwrite problem
Hello. I am trying to use fseek() to write something on the first line of my text file. The problem is that fseek() overwrites the already existing content of the first line to write the new one that i add by fputs(). What should i do? Thanks in advance!
2 Antworten
+ 3
fseek()? C#? Why does it look more C to me?
Be frank, is this for C# or C? These are different languages.
If the question is for C:
So you wish to have your new line 'before' the original data? Thus, if you were to add "Hello" to a file containing "World", should the new data in the file be - "HelloWorld" ?
For this, you need to get a new file, write the new data, then the old data, then remove the old file, and then rename the new one to the original name.
We have functions remove() and rename() in stdio.h for the same.
+ 1
Thank you very much and i am sorry for asking in the wrong language-chatroom