|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
Two dimensional array to a function My program scan multidimensional array and sends it to a function that will handle data entry in it. when I send the "array [] [nbAmis]" I get an error that tells me nbAmis not reported. Code: # include <iostream> using namespace std; int main () ( [...] de(nbAmis, table); [...] return 0; ) void de (nbAmis int, char array [] [nbAmis]) ( for (int i = 0; i <nbAmis; i + +) ( court << "Name of friend" <<i +1 << ""; cin>> array [i] [0]; ) ) |
#2
| |||
| |||
Re: Two dimensional array to a function Code: #include <iostream> using std::cout; using std::endl; double f(double values[][4], int f); int main() { double beans[3][4] = { { 2.0, 3.0, 4.0, 5.0}, { 55.0, 66.0, 77.0 88.0}, { 9.0, 10.0, 11.0, 12.0} }; cout << j(beans, sizeof beans/sizeof beans[0])<< endl; return 0; } double j(double array[][4], int size) { double sum = 0.0; for(int n = 0 ; n < size ; n++) for(int k = 0 ; k < 4 ; k++) sum += array[n][k]; return sum; } |
#3
| |||
| |||
Re: Two dimensional array to a function Two-dimensional arrays are a little more complicated to use than one-dimensional ones. Whereas, one dimensional arrays can be visualized as a stack of elements, two dimensional arrays can be visualized as a multicolumn table or grid. Try like this Code: void demandeNoms (nbAmis int, char * array []) |
#4
| |||
| |||
Re: Two dimensional array to a function Two-dimensional arrays are declared by specifying the number of rows then the number of columns. Code: int a[20][20]; (declares an int array of 20 rows and 20 columns) char ticTacToeBoard[4][4]; ( four rows and four columns of chars.) |
![]() |
|
Tags: data entry, function, multidimensional array, program |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help with two dimensional array java | GlassFish | Software Development | 3 | 30-11-2009 01:57 PM |
Dynamically allocate a two-dimensional array | Chrisch | Software Development | 3 | 24-10-2009 11:43 AM |
Function that returns a 2d array | Zool | Software Development | 3 | 10-10-2009 08:46 AM |
How to return an array from function | Rilex | Software Development | 3 | 02-10-2009 09:18 AM |
Three Dimensional Array program in Java. | nonose | Software Development | 3 | 10-08-2009 07:49 PM |