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 Crash after while with a number random

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



Joined: 29 Aug 2006
Posts: 2

PostPosted: Tue Aug 29, 2006 6:10 pm    Post subject: PSP Crash after while with a number random Reply with quote

Hello,

I have a problem with this code my psp crash and I do not understand why because it goes on LUA :

#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <png.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <graphics.h>
#include <fontloader.h>
#include <string.h>
#include <pspiofilemgr.h>

int grilleaffichage[9][9]={{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0}};

int hasard(int MAX) {
int nombreAuHazard;

srand(sceKernelLibcTime(NULL));
nombreAuHazard = rand() % MAX;

return nombreAuHazard;
}

int main() {
int i, ok, l, c;

for (i=1;i<=13;i++) {
ok=0;
while (ok==0) {
l=hasard(9);
c=hasard(9);
if (grilleaffichage[l][c]==0) {
grilleaffichage[l][c]=1;
ok=1;
}
}
}
}

can you help me thank you

Alkalamu
Back to top
View user's profile Send private message
Alkalamu



Joined: 29 Aug 2006
Posts: 2

PostPosted: Tue Aug 29, 2006 7:43 pm    Post subject: Reply with quote

I have resolved my problem

Change :

int hasard(int MAX) {
int nombreAuHazard;

srand(sceKernelLibcTime(NULL));
nombreAuHazard = rand() % MAX;

return nombreAuHazard;
}

int main() {
...
}

To :

int hasard(int MAX) {
int nombreAuHazard;

nombreAuHazard = rand() % MAX;

return nombreAuHazard;
}

int main() {
srand(sceKernelLibcTime(NULL));
...
}

And now is good

@++
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