forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

fread is not working properly?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development
View previous topic :: View next topic  
Author Message
MaikeruDev



Joined: 16 Jul 2007
Posts: 13
Location: Poland

PostPosted: Wed Nov 07, 2007 9:55 am    Post subject: fread is not working properly? Reply with quote

I noticed that fread function from PS2SDK isn't working properly, when I was trying to read something like that:
sample code:
Code:

unsigned int int_var;
unsigned short int sint_var;
FILE *some_fd = fopen("some_file_that_have_over_2MB","rb");
fread(&sint_var,1,2,some_fd); // this will be ok
fread(&int_var,1,4,some_fd); // this will be ok
fread(&sint_var,1,2,some_fd); // after this ftell function returns 0xffffffff


But when I changed 3rd fread to following code, it was ok.
Code:

fread(((unsigned char*)&sint_var)+0 ,1,1,some_fd);
fread(((unsigned char*)&sint_var)+1 ,1,1,some_fd);


It's happens also in other places in my code when I'm trying to read 2 bytes at time with fread. With one byte and four I haven't any problems.

Still I can use two fgetc (I saw this uses fread :) ) or just two times fread for one byte, but this is ugly :).

Have anybody similar issues?
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group