hello, I would require to Indentify and Remove a line from a txt file, any ideas?
#1

Okay so i would require to identify a line, then remove that specific line from the txt file?
Reply
#2

Bump'd proffesionaleh.
Reply
#3

uhm, maybe use dini? or dubd
Reply
#4

Currently am trying Dutils and fopen e.t.c. Il see if i can get success there, dudb,nor dini dont have the functions i require.
Reply
#5

Nop, it can't with dini, unsure about dudb.
Reply
#6

You can only use dini/dudb/etc if you actually have the file saved in their format

Anyways create a new file without the line you wanted and the rewrite the old file with the created one. Then delete the created one.
pawn Код:
new aLineFromTheFile[256];
new File:f = fopen("file.txt", io_read);
new File:temp = fopen("temp.txt", io_write);

while (fread(f, aLineFromTheFile))
{
    if (strcmp (aLineFromTheFile, "The line I want") == 0)
    {
        printf("This line won't get written in the temp file");
        continue;
    }
    fwrite(temp, aLineFromTheFile);
}
fclose(f);
fclose(temp);

//rewriting the original file with the temp one
f = fopen("file.txt", io_write);
temp = fopen("temp.txt", io_read);
while (fread(temp, aLineFromTheFile))
{
    fwrite(f, aLineFromTheFile);
}
Fremove("temp.txt");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)