C
C
CMETAHAA2016-03-13 12:27:43
C++ / C#
CMETAHAA, 2016-03-13 12:27:43

How to write to the very beginning of a line?

Now I read the manual and realized that it’s not possible to write text to the very beginning of the file? I'm talking about fopen.
I have a file where I need to delete 4 lines starting from 2-5 and replace with other 2 lines.

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:11
далее текст тра-татата.

And get this
#EXTM3U
#EXT-X-TARGETDURATION:5
#EXT-X-PLAYLIST-TYPE:VOD
далее текст тра-татата.

I added the line to the end without any problems. But how to start or replace

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GavriKos, 2016-03-13
@GavriKos

Read the entire file into a variable. In the variable, change what you need. You write the entire variable to a file, deleting everything that was there before.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question