fwrite - 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)
+--- Thread: fwrite (
/showthread.php?tid=326052)
fwrite -
Dennis_Smith - 16.03.2012
I'm trying to create and write to files. I'm getting errors on the line im using fwrite for. I'm not sure if im doing the handle part of it right. This is what is on the line.
Quote:
fwrite(testfile.txt, "This is test text.\r\n");
|
I'm not sure what the handle should be. Right now I have it as the name of the file. Help would be appreciated.
Re: fwrite -
antonio112 - 16.03.2012
Try opening the file first. Something like:
pawn Код:
new File:test = fopen("/testfile.txt", io_write);
fwrite(test, "This is test text.\r\n");
Re: fwrite -
Dennis_Smith - 16.03.2012
alright now here what i have.
Quote:
24 if(!fexist("testfile.txt"))
25 new File:test = fopen("/testfile.txt", io_write);
26 fwrite(test, "This is test text.\r\n");
27 fclose(test);
|
and here's the errors/warnings im getting for that.
Quote:
(25) : error 003: declaration of a local variable must appear in a compound block
(25) : warning 221: label name "File" shadows tag name
(25) : error 017: undefined symbol "test"
(26) : error 017: undefined symbol "test"
(27) : error 017: undefined symbol "test"
(25) : warning 203: symbol is never used: "File"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
|
Re: fwrite -
Dennis_Smith - 16.03.2012
alright so i figured out my idiotic problem... i forgot the {}'s it should look like this:
Quote:
if(!fexist("testfile.txt"))
{
new File:test = fopen("/testfile.txt", io_write);
fwrite(test, "This is test text.\r\n");
fclose(test);
}
|
Re: fwrite -
antonio112 - 16.03.2012
Quote:
Originally Posted by Dennis_Smith
alright so i figured out my idiotic problem... i forgot the {}'s it should look like this:
|
So, finally, does it work or ?