Please check my code, it has no error but there is something wrong.. I am trying to generate unique ten numbers from 0-99. then insert/store the generated number in an array(check[]) because later, after filling the array (check[]) with ten numbers, I am going to use it to another fuction with its ten unique elements. This is a part of my battleship game assignment.
#include <stdlib.h>
#include <stdio.h >
#include <time.h >
int generator ();
char comp [99];
char user [99];
int check [];
void main (){
clrscr ();
generator ();
getch ();
}
int generator () {
int cIndex, i, j , num;
srand((int)time(NULL));
for (i=0; i<=10 ; i++) {
cIndex = rand()%99+0;
for(j=0; j<=9 ; j++) {
if (cIndex!=check[j]) {
check[j]=check[cIndex];
}
else {
;;
}
}
}/*ENDFOR*/
printf ("%d",check[cIndex]);
}