vendredi 1 juillet 2016

How do you access data in a const char **& in C++?

example code: const char* list[] = {Elem_E, Elem_T, Elem_R, Turtle, Rabbit}; const char ** patterns=0; . . . bool sec_run = false; patterns = list; process_data(patterns, sec_run); process_data function: process_data(const char **& pattern, bool sec_run){ . . some_variable=0; for(int i; i < num_patterns;++i){ if(!sec_run){ some_variable = *pattern[i]; } else{ if(/* list element contains "_" */)continue; some_variable= /*letter after "_" */ } if(some_variable == 'E') multiplier = 0; else if(some_variable == 'T') multiplier = 1; else if(some_variable == 'R') multiplier = 2; } } So there is the base of what I'm trying to do. I cannot change signature for process_data. To start i do not get how some_variable = *pattern[i]; returns E,T, or R, and I cannot figure out how to iteratively access the full elements in the list. ie "Elem_E" to check for underscore and parse off the E. I have little background in C++, but have used C numerous times. I am having a difficult time finding visual representation for char **& to help with based understanding of what is going on here, if you can point in the direction of a good tutorial with visual that will also suffice.

Aucun commentaire:

Enregistrer un commentaire