0

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.

Reemahs
  • 5
  • 2
  • 5

2 Answers2

3
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;
};
  • 1
    +1 The fact that it says "pointer to integer", not "pointer to char", suggests that the prototype is missing, too, but this is definitely the main issue here. – Sergey Kalinichenko Feb 12 '13 at 16:15
  • 1
    Hey thanks that helped on the build and clean front. The prototype is declared. I should have included that with my question sorry :) – Reemahs Feb 12 '13 at 16:27
1

In your function declaration void print (char line1, char line2), line2 should be of type char * as menu is a character array

Ganesh
  • 5,880
  • 2
  • 36
  • 54