I am coding a GUI for my menu. The problem is this that when I access the drawtext function only the first element of my sub_menu char array is getting displayed when I access the function using
drawText(38,195,*a->sub_Menu[1],0);
drawText(38,240, a->sub_Menu[2],0);
drawText(38,285, a->sub_Menu[3],0);
drawText(38,330, a->sub_Menu[4],0);
and rest of the boxes show up blank. And when I try to access the drawtext funcion using
drawText(38,195,*a->sub_Menu[1],0);
drawText(38,240,*a->sub_Menu[2],0);
drawText(38,285,*a->sub_Menu[3],0);
drawText(38,330,*a->sub_Menu[4],0);
the program compiles and runs but as soon as I click on Settings button of my menu the program crashes saying myprogram.exe has stopped working. I don't know what the problem is as I am new to coding. Kindly Help me out.
typedef struct {
short startXPos;
short startYPos;
short height;
short width;
unsigned int c;
char *sub_Menu[5][18];
} menu, *ptr_Menu;
ptr_Menu a;
char sub_Menu1[5][18] = {"Big Font", "5 channel", "7 channel", "12 channel", "Alarm"};
menu touch_menu[10] = {30, 365, 45, 100, 5, &sub_Menu1};
void drawMenu(short b)
{
int k = 0;
if (b == 0) {
a = &touch_menu[0];
for (k=0; k<a->c; k++) {
setColor(GREY);
drawRectangle(a->startXPos, a->startYPos - (k+1)*a->height,a->width,a->height);
}
setColor(CYAN);
drawText(38,150,*a->sub_Menu[0],0);
drawText(38,195,*a->sub_Menu[1],0);
drawText(38,240,*a->sub_Menu[2],0);
drawText(38,285,*a->sub_Menu[3],0);
drawText(38,330,*a->sub_Menu[4],0);
}
}