Thread: error C2109

Results 1 to 5 of 5
  1. #1
    DreadKyller's Avatar
    Join Date
    Sep 2010
    Gender
    male
    Posts
    122
    Reputation
    12
    Thanks
    21

    error C2109

    I am makeing a menu, and have fixed all the errors, except for two errors I never heard of, and can't find any help with on the web.

    [PHP]void MRender(int ix, int iy,D3DCOLOR i_color){
    PrintText(ix+10, iy-10,_O_,pFont, "MenuTestV1.0");
    int ai=0;
    int i=0;
    while(ai<MMI){
    if(MENU[i].typ==(char)"FOLDER"){
    ai++;
    i_color=_R_;
    int val=(MENU[ai].var)?(*MENU[ai].var);
    PrintText(ix+10, iy-(15+(ai*8)), i_color,pFont, MENU[ai].txt);
    PrintText(ix+75, iy-(15+(ai*8)), i_color,pFont, MENU[ai].opt[MENU[ai].var]);
    }
    else{
    if(MENU[i].cm>0){
    ai++;
    int value=MENU[i].var;
    if(value==0){
    i_color=_B_;
    }
    else{
    i_color=_G_;
    }
    int item_num = MENU[i].var;
    PrintText((int)ix+25, (int)iy-(15+(ai*8)),i_color, pFont, MENU[i].txt);
    PrintText((int)ix+75, (int)iy-(15+(ai*8)),i_color, pFont, MENU[i].opt[item_num]);
    }
    }
    drawBox(ix, iy, 80, (ai*8),i_color,pDevice);
    }
    }[/PHP]

    and:

    [PHP]char *_Folder[]={"<+>","<->"};
    char *_on_off[]={"DISABLED","ENABLED"};
    char *_1to5[]={"DISABLED","2","3","4","5"};
    char *_off_2[]={"DISABLED","OPK","TELE"};
    char *_act_1[]={"INACTIVE","ACTIVE"};
    char *_color_[]={"Red","Blue","Green","Orange","Yellow","White"," Black"};[/PHP]in my menu I assign _Menu[Item].opt to one of these And what I am trying to do is print the item of the option that is corresponding to the variable _Menu[Item].var

    This is the error I get:
    Code:
    error C2109: subscript requires array or pointer type
    Can anyone tell me what is the problem, am I just missing something obvious, or is the code wrong?

  2. #2
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,193
    Reputation
    205
    Thanks
    1,438
    My Mood
    Mellow
    What line does it bring you to?

  3. #3
    DreadKyller's Avatar
    Join Date
    Sep 2010
    Gender
    male
    Posts
    122
    Reputation
    12
    Thanks
    21
    Code:
                PrintText(ix+75, iy-(15+(ai*8)), i_color,pFont, MENU[ai].opt[MENU[ai].var]);
    I get it twice, once for each time that appears.

  4. #4
    Moothew =^_^='s Avatar
    Join Date
    Oct 2010
    Gender
    female
    Posts
    148
    Reputation
    10
    Thanks
    56
    My Mood
    Amazed
    This could be the problem.

    Code:
    if(MENU[i].typ==(char)"FOLDER"){

  5. #5
    DreadKyller's Avatar
    Join Date
    Sep 2010
    Gender
    male
    Posts
    122
    Reputation
    12
    Thanks
    21
    no, the .typ variable is not even used in any lines near the line causeing the problem, the problem is either that it is not reconiseing MENU[ai].var as an int or that it is not reconiseing MENU[ai].opt as an array.

    Nevermind, I figured it out, fairly simple, I was just missing somethingobvious, here was my problem:

    Code:
    struct{
    	char typ;
    	char *txt;
    	char opt;
    	int var;
    	int cm;
    } _Menu[MMI];
    and:
    Code:
    addItem((char*)"No Flare",(char**)_on_off,&nFFlare,(char)"ITEM",&Visual);
    the problem was I was assigneing it to "int", I fixed it by just swiching it to "int**"

    Thank you anyways though.
    Last edited by DreadKyller; 10-31-2010 at 05:07 PM.