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 

PSP Crashes When Accessing File

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



Joined: 22 May 2005
Posts: 18

PostPosted: Tue Oct 11, 2005 7:54 pm    Post subject: PSP Crashes When Accessing File Reply with quote

I tried writing an app to access a file from the MS, but when I run the file, the PSP displays a black screen then turns off 10-20 seconds later.

Here is the code:

Code:
#include <pspdebug.h>
#include <pspiofilemgr.h>

PSP_MODULE_INFO("FileIOTest", 0, 1, 1);

int main()
{
   SceUID FileID;
   char *TestFile;

   pspDebugScreenInit();

   pspDebugScreenPrintData("File Access Test",16);

   FileID = sceIoOpen("ms0:/test.txt",PSP_O_RDONLY,0);

   pspDebugScreenSetXY(0,1);

   if (FileID == 0)
   {
      pspDebugScreenPrintData("Error Opening File",18);
   }
   else
   {
      pspDebugScreenPrintData("File Opened",11);

      sceIoRead(FileID,TestFile,10);

      pspDebugScreenSetXY(0,2);
      pspDebugScreenPrintData("File Accessed",13);

      pspDebugScreenSetXY(0,3);
      pspDebugScreenPrintData(TestFile,10);
   }

   while (1) {}

   return 0;
}


Where have I gone wrong?
Back to top
View user's profile Send private message
matkeupon



Joined: 02 Jul 2005
Posts: 26

PostPosted: Tue Oct 11, 2005 8:06 pm    Post subject: Reply with quote

Code:
char *TestFile;


This is a pointer to an array of char, but where is the actual array ?? In your example, it is not declared, so when you're writing into this array you're writing at a random place...

Replace it with this:
Code:
char TestFile[11]


That way, the compiler makes some room for the actual chars.
Back to top
View user's profile Send private message
Fabre



Joined: 22 May 2005
Posts: 18

PostPosted: Tue Oct 11, 2005 8:26 pm    Post subject: Reply with quote

Thanks, I'm not too experienced with C.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP 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