Hi everybody,
I have a problem and if you could help me as soon as possible I'll really appreciated
I have finished a C++ program but I've got a problem in a small part of the program ,I tried to solve it many times but so far I couldn't figure it out .
My problem was calling the two Dimensional array which is defined within main function.
To make it easier , Let's see the following :
_We have two dimensional array.
_User enters the two dimensions then we create 2d array inside the main function .
_ we want to write a function that takes such an array and its dimensions as its inputs and outputs many things such as maximum value in the array .
My problem as you know was you must define the other dimension in the function such as :
void display(int array [][3]){}
but since the user is the one who enters the number of rows and columns , then we call the function inside main function [ int main(){} ]
so, we don't know the dimensions until the user enters them .
Is there a solution for that ?
If yes , please give me an example (code),,,,,
#include<iostream>
using namespace std;
void function(int array[][],int r ,int c)
{
/*here we r going to perform many procedures such
as finding Maximum integer in the array*/
}
int main()
{ int ro,co;
cout<<"enter rows"<<endl;
cin>>ro;
cout<<"enter columns"<<endl;
cin>>co;
int ar[ro][co];
return 0;
}