Code:
#include <stdio.h>
int main(void){
int count, r_num[7], found, n;
srand (time(0));
for(count=0; count<7; count++){
do{
found=0;
r_num[count] = rand()%45+1;
for(n=0;n<count;n++){
if(r_num[n]==r_num[count]){
found=1;
break;
}
}
} while(found==1);
}
printf("%i %i %i %i %i %i %i",r_num[0],r_num[1],r_num[2],r_num[3],r_num[4],r_num[5],r_num[6]);
fgetc(stdin);
return 0;
}
Try lowering 45. The numbers will always be different, if you make 45 smaller than 7, the program never finishes the loop, because it hopes to find unused numbers in that range