#include <iostream>
#include <iomanip>
#include <ctime>
using namespace std;
char* InitializingMatrix(char start, char end) {
char matrix[9];
//Initializing random symbols to char massive
srand((unsigned)time(0));
for (int i = 0; i < 9; i++)
matrix[i] = (int)start + rand() % (int)end;
//Output matrix
for (int i = 0; i < 9; i++)
(i == 3 || i == 6) ? cout << endl << (char)matrix[i] << " " : cout << (char)matrix[i] << " ";
cout << endl;
return matrix;
}
void Output(char matrix[]) {
//Output matrix
for (int i = 0; i < 9; i++)
(i == 3 || i == 6) ? cout << endl << (char)matrix[i] << " " : cout << (char)matrix[i] << " ";
}
int main() {
Output(InitializingMatrix('1', '6'));
return 0;
}
Problem
The output of the matrix from the function for initializing the matrix and from the function for outputting the matrix are different.
Questions
Why output from InitializingMatrix and Output have differences?
How to fix it?