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



fread problem - Zaumao - 10.02.2009

hello to everyone. First sorry for my bad english.
My problem is the following ... I made a function to write to a file only when it reaches the loop while not working and not enough on the "print (" loop While ");":

pawn Код:
while(fread (file, strl, sizeof (strl)))
(
  print( "loop While");
I think it's because of the fread function. Is that it? Can help?
Thanks, and sorry if the question is being repeated, unable to solve my doubts following the information found.


Re: fread problem - yom - 10.02.2009

Check the fopen methods.


Re: fread problem - Zaumao - 10.02.2009

file = fopen(filename, io_read);
//file2 = fopen(filename, io_append);
I use this example:
https://sampwiki.blast.hk/wiki/File_Functions


Re: fread problem - Zaumao - 11.02.2009

The problem continues


Re: fread problem - Zaumao - 11.02.2009

HELP PLEASE!!!!111


Re: fread problem - Zaumao - 11.02.2009

I need help, please.


Re: fread problem - [RP]Rav - 11.02.2009

no need to post 4 times in a row..


Код:
new File: file, data[256];
file = fopen("put_filename_here", io_read);

while (fread(file,data))
{
  // funky bit goes here
}
fclose(file);
edit: also make sure the file exists


Re: fread problem - Zaumao - 11.02.2009

I did exactly this, but the error continues.


Re: fread problem - Zaumao - 12.02.2009

fread is bugged?


Re: fread problem - [RP]Rav - 12.02.2009

I read your first post again, you made a function that would write to a file, but then why would you bother with fread? since that only reads data from a file, it won't write anything to it, and you definatly can't do
Код:
while(fwrite(file,params));
that would be a never ending loop, and you also didn't open the file in a writing mode. Maybe you should take a look at a few references, if you still can't figure it out, please post your code and the error you're getting.