The input can be only 5, 7 or 9. Lets say in this case the input is 5, so the program generates 5 * 4 letters: "D E C B E D E D B D E D A C B E A A C B", now i need to put them into arrays of 4, so 5 char arrays, but I don't know how to do that. Here's how i generate the letters. I put all generated ones in one char array, but I also don't know how to separate it into smaller char arrays of 4. Another problem is, as I mentioned, the input changes in every run, but can be either 5, 7 or 9, so the program doesn't know how many arrays of 4 will it need.
I can't use vectors and can only use standard library because of the terms.
for (int i = 0; i < (input * 4); ++i) {
int n = (rand() % 5) + 1;
char kar = (char) (n + 64);
letters[i] = kar;
}
Here is how i print it, if I put all generated letters in one array:
for (int j = 0; j < input* 4; ++j) {
if (j % 4 == 0) {
cout << "\nLetters in the " << (j / 4) + 1 << ". array: ";
}
cout << letters[j] << " ";
}
I need the output like this as it is now, but with separated arrays.
Letters in the 1. array: D E C B
Letters in the 2. array: E D E D
Letters in the 3. array: B D E D
Letters in the 4. array: A C B E
Letters in the 5. array: A A C B