I tried my best but I can't figure out the problem. At the last part of "createArray", I output the final array created. I mean it to repeat once but then it repeat more times than I expect. createArray is an iterative function. If it repeats 3 times, than at last the array created which fulfil the criterion would be printed out 3+1 times.
I am trying to create an array with 3 numbers 5 times, resulting in a 2D array. The 3 numbers in a array are picked from 0 - 5. I enter createArray(5,3,5). Then these 5 arrays are compared with each other to see if there are repetitions. If there are, the whole process begins again, 5 arrays with 3 numbers each will be picked again and compared with each other. If there are no repetitions at last, there 5 arrays would be printed out.
Hi, @tcs, thanks for your reply.
I am pretty new to c++. By " You've forgotten to assign the newly created array to Array", I think I did it in Line 17? Between Line 30 and Line 31, I initialized Array again by putting this line in between,
In line 17 you've assign values to Array elements while in line 12 you've assign a value, an array of int*, to the variable Array itself. In line 30 you've destroyed this value (array of int*) so further access to Arrays elements result in undefined behaviour (usually a process crash). In line 31 you've called createArray recursivly to create a new array, which I think you want to use as Arrays new value. So write:
Hi, tcs, thanks first of all.
Previously, for the last loop from L41 to L46, the array is printed out more than once. The repetition depends on how many times createArray is called. Now I've change the line as suggested by you, the situation is still the same ......