int main ()
{
char a, i, j;
int rows, columns;
int max, min;
srand (time(NULL));
for (int i = 1; i <= 3; i++)
{
rows = rand () % 6 + 5;
columns = rand () % 5 + 5;
construct2D ( a, rows, columns);
print2D ( a, rows, columns);
}
}
int k;
const char ALPHANUMERIC [] ={"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"};
char mapping ( int k )
{
char i = ALPHANUMERIC [k];
return i;
}
void construct2D (char a [][MAXCOL], int rows, int columns)
{
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < columns; j++)
{
k = rand () % 61 + 1;
a [i][j] = mapping(k);
}
}
}
void print2D (const char a [][MAXCOL], int rows, int columns)
{
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < columns; j++)
{
cout << " ' " << a [i][j] << " ' " << "\t";
}
You are trying to pass type char to a 2-dimensional char array.
a is a char. So make sure you declare a as a 2-dimensional char array or find another way.
After you make a a 2-dimensional array with the 2nd dimension having a size of 8 then you won't have any more errors (tested). If you find another way I wouldn't know.
You should declare it like char a[sizeHere][MAXCOL], i, j;
You wouldn't do this right?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
void print(int x) // type int
{
std::cout << x;
}
int main()
{
double x = 3.141; // type double
print(x); // 3.141 will turn into 3 because x in print(int x) is int
// so you will lose the value 3.141
return 0;
}