AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   replacing a whole line in a file with nothing (https://forums.alliedmods.net/showthread.php?t=49551)

[ --<-@ ] Black Rose 01-06-2007 20:24

replacing a whole line in a file with nothing
 
EDIT:
New question.
Lets say I have line text wich equals "^r". I want to replace this with "" meaning i would like to delete the line, would this be possible? i've tryed fprintf and fputs but I'm not really getting anywhere with it... everytime it prints at the end of the file.

I would like doing this with the new file natives and without creating a temp file.

Current Code:
Code:
stock test() {         new data[64], fileh = fopen("addons/amxmodx/test.txt", "r+");         if ( ! fileh )         return         while ( ! feof(fileh) ) {                 fgets(fileh, data, 63);                 if ( equal(data, "^n") ) {             // ?             // fprintf(fileh, "") neither of these             // fputs(fileh, "") worked well         }             }         fclose(fileh)     }

p3tsin 01-07-2007 07:15

Re: fopen modes, read + write in one file.
 
Quote:

Originally Posted by [ --<-@ ] Black Rose (Post 424480)
How do you use fopen to read AND write to a line/file?
I've tryed different modes, "r+w", "w", "a+", "a", "+"... none would work. I mean, some would read them, and some would just go on forever and read nothing and one of them would start printing some lang like "do not flood" in 5 different languages, replacing my lines.

that would be r+t
http://www.cplusplus.com/reference/c...dio/fopen.html

Deviance 01-07-2007 07:42

Re: fopen modes, read + write in one file.
 
at+

[ --<-@ ] Black Rose 01-07-2007 11:13

Re: fopen modes, read + write in one file.
 
Quote:

Originally Posted by p3tsin (Post 424631)

Thank you!


All times are GMT -4. The time now is 22:27.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.