Hi,
Does anyone have a good page and some exercises on the use of pointers?
The compiler is Source Boost and the target is an 18f picr. I am trying
to find out why the code below won't compile. At line 244 I get invalid
operand and failed to generate expression.
Thanks
char get_credit (void)
{
char test_string[]="Your balance is £4.38.";
//char *CUSD = "AT+CUSD=1,*#10 #";
char *pnd_point;
char *dec_point;
int length;
char cb [5];
//char pnd='£';
//char dec='.';
int credit_pnd;
int credit_pence;
//puts ("AT+CUSD=1,*#1 0#");
//gsm_gets (rx_array);
strcpy (rx_array,test_ string);
pnd_point =strchr (rx_array,'£');
dec_point =strchr (rx_array,0x2E) ;
length =(pnd_point - dec_point); // <-----line 244
strncpy (cb,(pnd_point+ 1),(length));
credit_pnd = atoi (cb);
strncpy (cb,(dec_point+ 1),2);
credit_pence = atoi (cb);
if (credit_pnd >5)
{
portb.0 = 1;
portb.1 = 0;
}
else
{
portb.0 = 0;
portb.1 = 1;
}
}
Does anyone have a good page and some exercises on the use of pointers?
The compiler is Source Boost and the target is an 18f picr. I am trying
to find out why the code below won't compile. At line 244 I get invalid
operand and failed to generate expression.
Thanks
char get_credit (void)
{
char test_string[]="Your balance is £4.38.";
//char *CUSD = "AT+CUSD=1,*#10 #";
char *pnd_point;
char *dec_point;
int length;
char cb [5];
//char pnd='£';
//char dec='.';
int credit_pnd;
int credit_pence;
//puts ("AT+CUSD=1,*#1 0#");
//gsm_gets (rx_array);
strcpy (rx_array,test_ string);
pnd_point =strchr (rx_array,'£');
dec_point =strchr (rx_array,0x2E) ;
length =(pnd_point - dec_point); // <-----line 244
strncpy (cb,(pnd_point+ 1),(length));
credit_pnd = atoi (cb);
strncpy (cb,(dec_point+ 1),2);
credit_pence = atoi (cb);
if (credit_pnd >5)
{
portb.0 = 1;
portb.1 = 0;
}
else
{
portb.0 = 0;
portb.1 = 1;
}
}
Comment