fread function
#1

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?
Reply
#2

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

The word "hey"
Reply
#4

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

In my scriptfiles folder :P
Reply
#6

Try this.

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

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..
Reply
#8

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


Forum Jump:


Users browsing this thread: 1 Guest(s)