SA-MP Forums Archive
fread function - 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: fread function (/showthread.php?tid=234482)



fread function - Franjdea - 03.03.2011

This is doing my head in, I haven't used files for a while, as I find a MySQL database a lot more convenient and organised, but today I decided I would try it for another project. I went to the wiki and looked at the file tutorial, understood it etcetera, and when I try to execute the example code, this is my output:

[21:35:59] яюh

This is the code

pawn Код:
new filestring[256]; // Create the string to store the read text in
new File:example = fopen("text.cfg", io_read); // Open the file
fread(example, filestring); // Fread from the file and store what's read in 'string'
printf("%s", filestring); // Print what was read
fclose(example); // Close the file
Anyone got any ideas?


Re: fread function - JaTochNietDan - 03.03.2011

I just tested that code and it works as intended. What are the contents of your text.cfg file?


Re: fread function - Franjdea - 03.03.2011

The word "hey"


Re: fread function - JaTochNietDan - 03.03.2011

That's odd, just tested that, working without any issues. Where is your text.cfg file located?


Re: fread function - Franjdea - 03.03.2011

In my scriptfiles folder :P


Re: fread function - Antonio [G-RP] - 03.03.2011

Try this.

pawn Код:
new File:example = fopen("/text.cfg", io_read); // Open the file



Re: fread function - Lorrden - 03.03.2011

Quote:
Originally Posted by Antonio [G-RP]
Посмотреть сообщение
Try this.

pawn Код:
new File:example = fopen("/text.cfg", io_read); // Open the file
Shouldn't be needed..

Try running pawno as an Administrator once?
I know this has caused alot of troubles for me when reading/writing files or includes..
Otherwise, perhaps you're using too much data or something?
make Your string smaller?

"hey" doesn't need a 256 string..


Re: fread function - Antonio [G-RP] - 03.03.2011

Quote:
Originally Posted by Lorrden
Посмотреть сообщение
Shouldn't be needed..
Haven't worked with files in ages, not sure.