Logic array in C -


i trying test logic function 4 inputs a,b,c , d.

each input either 0 or 1.

i have been trying accomplish arrays.

i want pass 1 if column in logicxy array matches of comblogic array.

int comb(int** comblogic, int** logicxy){     int x, y, logicout;     ( x = 0; x < 4; x++ ){         if (logicxy[0][x] == comblogic[x]){                 logicout = 1;                 }     }     return logicout; }   int main void(){     int** comblogic[4] = {a,b,c,d};  /*logic input*/     int** logic[4][4] = {{1,0,0,1}, {1,0,1,1}, {0,1,0,0}, {0,1}}; /*return 1 if of these combinations match logic input*/     int comb(comblogic, logicxy); /*send function*/ } 

i know function not complete don't think passing arrays correctly. have read number of tutorials cant seem grasp theory.

edit have got few steps forward still isn't working. have now.

function declaration in .h

int comb(logicinput,logictest); 

function in .c

/* function - combination */ int comb(int** logicinput, int** logictest){ int x, y, logicout;     ( x = 0; x < 4; x++ ){         if (logictest[0][x] == logicinput[x]){                 logicout = 1;                 }     }     return logicout; } 

the loop in part of main.c

int output = 0; int logicinput[4] = {0,1,1,1}; int logictest[4][4] = {{1,0,0,1}, {1,0,1,1}, {0,1,0,0}, {0,1,1,1}}; int comb(logicinput,logictest); output = comb; 

the code steps on int comb(logicinput,logictest) , never carries out function. if take out int line carries out function, returns value when value written output nothing value returned function.

edit

i have made few changes code appear work , 1 warning compiler function declaration in .h cannot seem fix.

warning: parameter names (without types) in function declaration [enabled default] 

function declaration in .h

int comb(logicinput,logictest); 

function in .c

int comb(int** logicinput, int** logictest){ /*points arrarys in main   program*/ int x, i, logicout;     for(i = 0; < 4; i++){ /*test each column*/      ( x = 0; x < 4; x++ ){ /*test each row*/       if (logictest[i][x] == logicinput[i][x]){             logicout = 1;             break;             } }    if(logicout == 1)break; /*break when logicout == 1 first time happens*/ } return logicout; } 

loop in main.c

int output; int logicinputc1[4] = {0,1,0,1}; int logictestc1[4][4] = {{1,0,0,1}, {1,0,1,1}, {0,1,0,0}, {0,1,0,1}}; output = comb(logicinputc1,logictestc1); 

if deviate code seem end compiler failing build , more warnings.

int * comblogic[4] = {a, b, c, d} //where a, b, c, , d, arrays of size 4; aka int     a[4]; int logicarray[4][4] = values;  

in loop:

int comb(int** comblogic, int** logicxy){     int x, y, logicout;     for(int = 0; < 4; i++){      ( x = 0; x < 4; x++ ){       if (logicxy[i][x] == comblogic[i][x]){             logicout = 1;             break;             } }    if(logicout == 1)break; //incase want break when logicout == 1 first time happens } return logicout; } 

Comments