??? 07/29/06 17:27 Read: times |
#121316 - While theoritically it should works... Responding to: ???'s previous message |
First of all, thank you for the very quick response but i understand well what are you trying to point out here.
But in my case, instead of declaring char array[sizeof("12.34")], i did a fixed size for the array such that : char array[8]; and i certainly hope there is no problem with it. anyway to make things clearer about what i want to do, i want to actually output each and every of the digits to the LCD (of course as character strings)so that it can be displayed. I have the LCD printing function as follow : void LCD_Print (char *str) { SetLCD (InstReg, 0x02); // Return Cursor to Home for (; *str != '\0'; str ++) { if (*str == '\n') { SetLCD (InstReg, 0xC0); //New line } else { SetLCD (DataReg, *str); } } } This function works perfectly for the following : - LCD_Print("Hello World"); - LCD_Print("12.34"); But the problem lies here is how can i print arbitrary floating point number that is obtained from external output which is stored inside a floating point variable. I tried the following after reading your post : . . char LCD_Buffer[8]; . . long test; . . test = 12.34; sprintf(LCD_Buffer, "%.2f", test); LCD_Print(LCD_Buffer); . . but the LCD only shows up a string of ????? (garbage) so i think there must be some sort of mistake that i made. Can you point out what the mistake i had probably made? |
Topic | Author | Date |
Interger to Array and Buffer question | 01/01/70 00:00 | |
Answers | 01/01/70 00:00 | |
While theoritically it should works... | 01/01/70 00:00 | |
float conversion specifier on a long | 01/01/70 00:00 | |
Alright | 01/01/70 00:00 | |
what is that, never heard of it![]() | 01/01/70 00:00 |