2-d array function calling
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
void function1(char array[][80], int r, int c)
{
for (int i=0; i<r ; i++)
{
for (int j=0; j<c ; j++)
{
cout << array[i][j];
}
cout << endl;
}
}
void function2(char array[][80], int r, int c)
{
for (int i=0; i <= r-1 ; r--)
{
for (int j=0; j<= c-1 ; j++)
{
cout << array[r-1][j];
}
cout << endl;
}
}
void function3(char array[][80], int r, int c)
{
for (int i=0; i<r ; i++)
{
for (int j=0; j<=c-1 ; c--)
{
cout << array[i][c-1];
}
cout << endl;
}
}
|
output:
abcdefghij
bcdefghijk
cdefghijkl
defghijklm
efghijklmn
efghijklmn
defghijklm
cdefghijkl
bcdefghijk
abcdefghij
jihgfedcba
|
------------------------------problem here is that it doesnt print out the next array row on function 3.
what am i doing wrong? these are the callers of the function:
function1(array, 5,10);
function2(array, 5,10);
function3(array, 5,10);
< all the same.
Last edited on
Topic archived. No new replies allowed.