Hy im having a big problems...
Im trying to pass pointer by reference of struct array to function here is my function with struct
Code:
struct TCLIENT_INFO{
int clientid;
int sock;
unsigned char buffer[1024];
int bconnected;
long tickconnected;
long ticklastrec;
long ticklastsnd;
unsigned char packet_err;
unsigned char packet_waits;
unsigned char token[8];
};
int addcli(struct TCLIENT_INFO** cli_info, unsigned short *ustop){
int stat = 0;
//increase top bound
ustop++;
printf("CLI Info Pointer: %p\n", *cli_info);
if(ustop > 0){
if(*cli_info==NULL){
*cli_info = realloc(NULL,(ustop * sizeof(struct TCLIENT_INFO)));
}else{
*cli_info = realloc(*cli_info,(ustop * sizeof(struct TCLIENT_INFO)));
}
}else if(ustop == 0){
}
return stat;
}
//this main prog is for testing
int main(){
struct TCLIENT_INFO *cli;
unsigned short cli_slots = 0;
struct TCLIENT_INFO *cl2;
printf("%d\n",addcli(&cli,&cli_slots));
free(cli);
return 0;
}
i get this error
test.c: In function âaddcliâ:
test.c:64: error: invalid operands to binary *
test.c:66: error: invalid operands to binary *
test.c:69: error: invalid operands to binary *
line 64 is *cli_info = realloc(NULL,(ustop * sizeof(struct TCLIENT_INFO)));
line 66 is *cli_info = realloc(*cli_info,(ustop * sizeof(struct TCLIENT_INFO)));
line 69 is *cli_info = malloc((ustop * sizeof(struct TCLIENT_INFO)));
please help