Hi, I need your piece of advice. I am kind of novice to programming C. I am trying to create a Generic LCD_printf function, that can print decimals, string, characters.
The following is the code i am trying
#include <all necessary h file> // declaration void lcd_printf (const char *,...); //definition void lcd_printf(const char *identifier, const int idata *datastring) { char id; while (*identifier !='\0') { if (*identifier == '%') { identifier++; id = *identifier; switch (id) { case 'd' : dectolcd(datastring); // converts decimal to string break; } } else { _lcd_data(*identifier); // prints the character in LCD } identifier++; } } void dectolcd(int *datastring) { char *temp; sprintf(temp,"%d",datastring); // converts decimal to string lcd_display(temp); // prints string on the lcd } Void main { lcd_printf("%d",123); }
Now when I run this code, I am not getting the 123 on the LCD. I know i am messing with the pointers somewhere. Can someone help as what i can do better ??