when I try to compile my code below I get the following errors:
error C2440: ‘>=’ : cannot convert from ‘double *’ to ‘double’
error C2440: ‘>=’ : cannot convert from ‘double *’ to ‘double’
I believe I’m dereferencing everything correctly
#define TRUE 1
#define FALSE 0;
#include <stdio.h>
typedef struct Con{
double samTime[2];
double sen[2];
int test[2];
} CON, *CON_PTR;
void GM(double **TTXY) {
int NoS;
int numOfSen = 2;
int startTime =0;
CON con;
if((con = (CON_PTR) malloc(numOfSen*sizeof(CON)))==NULL) {
printf(“Malloc failed\n”);
exit(1);
}
for (NoS=0;NoS<numOfSen;NoS++) {
con[NoS].samTime[0] = startTime;
con[NoS].samTime[1] = startTime;
con[NoS].sensor[0] = 0;
con[NoS].sensor[1] = 0;
con[NoS].test[0] = FALSE;
con[NoS].test[1] = FALSE;
}
if (con[NoS].samTime[0] >= TTXY[1]) {
con[NoS].test[0] = TRUE;
}
if (con[NoS].samTime[1] == TTXY[1]) {
con[NoS].test[1] = TRUE;
}
}
First, there’s a missing semicolon
and your main function is not correct, this must be one of
and as to your question, no you’re not dereferencing it right, as your
TTXYarray is 2-dimensional. So it should be something likewhatever works for your code. And you should use more descriptive names for your variables if others are supposed to understand the code.
If
TTXYshould really be a one-dimensional array, then you don’t need to pass it by reference (function(&TTXY)), passing the pointer value (function(TTXY)) will be enough and more readable.