I have a really annoying problem...
I have to be able to display some text from a structure onto an LCD display from micro controller.
These are the affected areas:
struct menu_id {
char id;
char menu[11];
char submenu;
};
void main (void){
struct menu_id mainmenu[5] = {
{0, "CHNL1", 1},
{0, "CHNL2", 2},
{0, "Mal Codes", 3},
{1, "CHNL1...", 0},
{2, "CHNL2...", 0},
};
print(mainmenu[0].id, mainmenu[0].menu);
}
void print (char line1, char line2)
{
char temp[11];
LCD_Register_Com(); //Set to Command Register
OutputChar(LCD_Line0); //Line 0,0
LCD_Register_Data(); //Set to Data Register
sprintf(temp, "%c", line1);
OutputString(temp);
LCD_Register_Com(); //Set to Command Register
OutputChar(LCD_Line1); //Line 1,0
LCD_Register_Data(); //Set to Data Register
sprintf(temp, "%c", line2);
OutputString(temp);
}
Everytime I try to build the code it throws up this error Main_Test.c:108: warning: illegal conversion of pointer to integer for when I call the print function, "print(mainmenu[0].id, mainmenu[0].menu);".
Any help would be much appreciated.
Thank you.
void print (char line1, char line2)
change to
void print (char line1, char* line2)
and
sprintf(temp, "%c", line2);
to
sprintf(temp, "%s", line2);
With
mainmenu[0].menu
You are passing a string not a char to the function.
struct menu_id {
char id;
char menu[11]; <- string
char submenu;
};