I'm quite new to C++ and I wanted to start out with a program generating 4x4 sudoku grids. I'm just getting started, but for some reason my program prints out 4 numbers in a line (different ones, so that's nice) but then loads endlessly. I know it's probably a stupid qestion, but here's my code if anyone might care to have a look (don't worry about all the #include, I tried different things out) thanks a lot!
EDIT : I forgot to tell, the program started doing that once I implemented the srand(time(NULL)) in it
EDIT2 : This isn't because I'm calling srand several times, I tried a different version with srand before both for and it's still the same
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main() {
int nbs[4][4];
int l = 0;
int c = 0;
int val;
int check;
for (l = 0; l < 4; l++) {
srand(time(NULL));
for (c = 0; c < 4; c++) {
check = 0;
while (check == 0) {
nbs[l][c] = rand() % 4 + 1;
val = nbs[l][c];
if (val == nbs[l][c - 1]) {
}
else if (val == nbs[l][c - 2]) {
} else if (val == nbs[l][c - 3]) {
} else if (val == nbs[l - 1][c]) {
} else if (val == nbs[l - 2][c]) {
} else if (val == nbs[l - 3][c]) {
} else {
check = 1;
cout << nbs[l][c];
}
}
}
cout << "\n";
}
cout << "hello world!";
return 0;
}