Question
Point to a char array for displaying on LCD?
Posted on May 24, 2014 at 16:27
Hi, i have a bmp085 bosch pressure&temp sensor, wich i want to show my data in format 4 degree
The raw readings are ok, i have the following code goinguint8_t tlsb;
uint8_t tmsb;
uint16_t temp;
char txt[10];
tmsb=i2c_rdack(I2C1);
tlsb=i2c_rdNack(I2C1);
temp=(tmsb<<8)+tlsb;
sprintf(txt,''%d'',temp); // converts int to string
char *ch1;
char *ch2;
char *ch3;
ch1=&txt[0];
ch2=&txt[1];
ch3=&txt[2]; UB_LCD_2x16_String(0,1,txt); // if i use only this, it shows me 254 value, wich is corect since i have 4 degree
but i wanna split the chars so i can add comma''.'', the result i wanted to be like this
UB_LCD_2x16_String(0,1,ch1); // displays first digit ( 2)
UB_LCD_2x16_String(0,1,ch2); // displays second digit (5)
UB_LCD_2x16_String(0,1,''.''); // displays only a dot (.)
UB_LCD_2x16_String(0,1,ch3); // displays the last digit (4)
The problem is at the pointing trough the txt char array. I`m not so familiar to standard c, used only mikroc builtin libs. Have any idea how to point
Thanks
#string #c-learning #c-string