File function newline (\n) problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: File function newline (\n) problem (
/showthread.php?tid=201525)
File function newline (\n) problem -
iggy1 - 21.12.2010
Well i've never realy needed to use the native file functions untill now, i need to make some logs. However whenever i use a newline charachter instead of printing on a new line its printing to the same line. Where the newline is meant to be there is a rectangle symbol (don't know the name sorry). I cant post the symbol. (it prints a newline on the forum). I know its probably a silly problem but if someone has the solution i'd appreciate it alot.
Heres some example code,
pawn Код:
public OnPlayerText(playerid, text[])
{
new
File:tfile = fopen("chatlog.txt", io_append);
format(text, 128, "%s\n", text);
fwrite(tfile, text);
fclose(tfile);
return 1;
}
Thanks in advance.
Re: File function newline (\n) problem -
The_Gangstas - 21.12.2010
try \r\n instead of \n only
Re: File function newline (\n) problem -
iggy1 - 21.12.2010
Thats not the problem all /r does is make the next text start at the beggining of a line. If i did that i would get 2 of them rectangle symbols. Thanks though.
This is the file after 3 words,
http://solidfiles.com/d/4a11/ (wont display right here)
Re: File function newline (\n) problem -
Marcel - 21.12.2010
io_append has to be io_write.
Re: File function newline (\n) problem -
Face9000 - 21.12.2010
Quote:
Originally Posted by Marcel
io_append has to be io_write.
|
This doesnt mean nothing. io_write will create a new file everytime, io_append will write on each line.