1

i have a two dimensional array that i want to pass through a function

char blendModeOptions[18][16]={"Normal","Darken","Multiply","Color Burn","Linear Burn","Lighten","Screen","Color Dodge","Linear Dodge","Overlay","Soft Light","Hard Light",
    "Vivid Light","Linear Light","Pin Light","Difference","Exclusion","Hue"};

blendMode = KIT_CreateSelectOption(blendModeOptions,18,&blendModeRect);

and the declaration of the function is:

KIT_SelectOption * KIT_CreateSelectOption(char ** options,int size ,SDL_Rect * rect);

i got a warning :

note: expected 'char **' but argument is of type 'char (*)[16]'

inside the function i call a function int KIT_AddOption(KIT_SelectOption *box, const char * option); by this argument KIT_AddOption(box,options[i]);

my program crushes when i in this line of code in KIT_AddOption

strcpy(opt->name,option);

i have tried char * option[16] istead of char ** option but it doesn't work.

1 Answers1

6

You need to define your array as array of pointers, instead of 2D char array.

char *blendModeOptions[]={"Normal","Darken","Multiply","Color Burn","Linear Burn","Lighten","Screen","Color Dodge","Linear Dodge","Overlay","Soft Light","Hard Light",
"Vivid Light","Linear Light","Pin Light","Difference","Exclusion","Hue"};
sklott
  • 1,308
  • 1
  • 10