Arrays and functions

Hey guys,

What I am trying to do is get this 2darray to pass to the function. The code looks weird simply because I have cut everything down to basically nothing to try and figure this out but I think I need a helpful hand. It won't compile and i'm not sure why it give be an error code that says "invalid conversion from int to int [*][2}" on line 29 and line 35 it says "expected ',' or '...' before numeric constant" can you guys tell me what I am doing wrong?

thanks in advance.

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
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <iomanip>
#include <conio.h>

using namespace std;

//declaring Functions

int gettotal (int[5][2], int);
int getaverage (int, int);
int getcolumntot (int, int);
int getlowinrow (int, int);

int array1[5][2] = {   {10,20},
				  	   {30,40},
				  	   {50,60},
				  	   {70,80},
				   	   {90,99} };

int main()
{	 	 	 	 	 	    
	int total;
	
	for (int i = 0; i<5; i++)
		for(int n = 0; n<2; n++)
		
		cout << array1[i][n];
		
	gettotal(array1[5][2], 10);
			
			
	return 0;	 
}

int gettotal(int array1 [5][2], int 10)

{
	cout << "function";


}




When passing arrays as parameters, you only need to pass the variable name and not the dimensions of the array. So line 29 should look like this instead:
gettotal( array, 10 );

The issue on line 35 is that you've used an invalid variable name for one of your parameters. "int 10" is not allowed because variables must start with either a letter or an underscore. So this would be a more appropriate line:
int gettotal(int array1[5][2], int ten) { /* function code */ }
Hi keene,

You are the man that worked!

Thanks for your help!!!
Topic archived. No new replies allowed.