This function accepts an int, and fill an array of 10 ints with that value, and retus a pointer to that array. How can I do the same thing but retu an reference to an array?
int (*g(int n))[10]
{
int (*ptr)[10] = (int (*)[10])malloc(sizeof(int) * 10);
for (int i = 0; i < 10; i++) {
(*ptr)[i] = n;
}
retu ptr;
}
Something like
int (&h(int n))[10]
{
// How to do this
int (&ref)[10] = ???;
for (int i = 0; i < 10; i++) {
ref[i] = n;
}
retu ref;
}
