Geting second dimetion from array

 

Hi, I have some problem, I have function that in a specific way compares two arrays (same size). I have big 2-diemntion array data[1000][8]. How to call my function?

fnCompare(data[0], data[1]);
It doesn't work. How to get this eight-element array?

            
 

That depends on what arguments your function requires. You haven't given enough information to answer the question here.

These two articles should contain all the information you need to answer your question, when applied to the function you already have.

Explanation of arrays - https://book.mql4.com/variables/arrays

Explanation of functions - https://book.mql4.com/basics/functions

- n.b. since you say your "data" array is 2-dimensional, then you should be refering to it as data[x][y].

 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void start(){
    string data1[2][2]={
        "data1_row0_colum0","data1_row0_colum1",
        "data1_row1_colum0","data1_row1_colum1"
    };
    string data2[2][2]={
        "data2_row0_colum0","data2_row0_colum1",
        "data2_row1_colum0","data2_row1_colum1"
    };
    fnCompare(data1, data2);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void fnCompare(string data1[][], string data2[][]){
    Print("data1_row1_colum1="+data1[1][1]);
    Print("data2_row1_colum1="+data2[1][1]);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
void start(){
    string data1[2][2]={
        "data1_row0_colum0","data1_row0_colum1",
        "data1_row1_colum0","data1_row1_colum1"
    };
    string data2[2][2]={
        "data2_row0_colum0","data2_row0_colum1",
        "data2_row1_colum0","data2_row1_colum1"
    };
    fnCompare(data1[0], data2[0]);
}

void fnCompare(???, ???) {
   //how to build this function to get inside, a row from each array as one dimension array??
}
 

I don't understand your question.

Try reading the Book and don't skip chapters.

The below code will not compile.

fnCompare(data1[0], data2[0]);
 
darkfox:

Hi, I have some problem, I have function that in a specific way compares two arrays (same size). I have big 2-diemntion array data[1000][8]. How to call my function?


Have you tried:

double data[1000][8]
fnCompare(data[0], data[1]);
/////////////////////////////////////////
void fnCompare(double A[8], double B[8]){

I'd personally code it as:

double data[1000][8]
fnCompare(data, 0, 1);
/////////////////////////////////////////
void fnCompare(double data[][8], int i, int j){
   if (data[i][0] == data[j][0])...
Reason: