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