Im writing a program to give the user options whether they want to:
- Add random numbers to an array
- Print array
- Search for an element in an array
- Left shift array
These have to be in separate functions and it needs to b recursive and until the user wants to finish it keeps running my code is:
int main()
{
    int array[M][N];
    int ans;
    puts("Please enter what you would  like to do:\n
            1: Create an array with random values\n
            2: Print Array\n
            3: Search for a number in an array\n
            4: Shift each value to the left");
    scanf("%d",&ans);
    switch(ans) {
        case 1:
            PopulateRandom2D(array);
            break;
        case 2:
            PrintArray(array);
            break;
        case 3:
            LinearSearch2D(array);
            break;
        case 4:
            LeftShift(array);
            break;
        default:
            puts("Goodybye");
            return 0;
    }
    main();
    return 0;
}
void PopulateRandom2D(int array[][N])
{
    int r,c;
    srand(time(NULL));
    for(r = 0; r < M; r++) {
        for(c = 0; c < N; c++) {
            array[r][c] = 1 + (rand() % (M * N));
        }
    }
}
After i call the function i need the user to enter another command and call a different function from the user input. Ive been experimenting by first hitting 1 so it fills the array with numbers and then hitting 2 so it will hopefully print out that array but all i get are huge numbers in the array. I don't think the function is editing the array in main correctly so main doesn't get the array with random values but how do i fix this?
 
     
    