I want to allocate variable sized 2D array in a function without using new operator such that this 2D array is available to other functions in the same file.
void draw(int i)
{ size=i; }
void assign(char symbol)
{
char one[size][size];
/// ... Assigning values to one ...
}
void display()
{ /// Displaying values of one[size][size]
for(int i=0;i<size;i++)
{
for(int j=0;j<size;j++)
cout<<one[i][j];
cout<<endl;
}
}
Execution order of functions is draw -> assign -> display
This question may have been asked earlier. But my problem is.. -> I can't declare the array outside assign function globally because value of size is not known. -> I can't use "one" array in "display" function because its scope is limited to "assign" function.
And I also don't want to use either new or malloc operators. Please help if there is any alternative available.