 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Fabre
Joined: 22 May 2005 Posts: 18
|
Posted: Tue Oct 11, 2005 7:54 pm Post subject: PSP Crashes When Accessing File |
|
|
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 |
|
 |
matkeupon
Joined: 02 Jul 2005 Posts: 26
|
Posted: Tue Oct 11, 2005 8:06 pm Post subject: |
|
|
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:
That way, the compiler makes some room for the actual chars. |
|
| Back to top |
|
 |
Fabre
Joined: 22 May 2005 Posts: 18
|
Posted: Tue Oct 11, 2005 8:26 pm Post subject: |
|
|
| Thanks, I'm not too experienced with C. |
|
| Back to top |
|
 |
|
|
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
|