Hi everyone,
I have the following function, I use it to read tags from a xml file. It returns true when it is able to read and false when something fails. I also update the values of "node_start" and "node_end" so I can keep track of the values read from outside. Here is the code:
The problem I'm having is the values of node_start and node_end that aren't being passed as reference, but by value - they do not update their values outside the function. Here is where I call the function:Code:bool getNode(char *begin, char *end, const char *name, char *node_start, char *node_end) { string starttag = "<",endtag = "<"; starttag += name; starttag += ">"; endtag += "/";endtag += name;endtag += ">"; char *_node_start = strstr(begin,starttag.c_str()); if((_node_start == NULL)||(_node_start >= end))return false; char *_node_end = strstr(_node_start+starttag.length(),endtag.c_str()); if((_node_end == NULL)||(_node_end >= end))return false; node_start = _node_start; node_end = _node_end + endtag.length(); return true; }
I'm sure I'm missing something kind of obvious, but I just can't see it. Can you help me?Code:char *node_start = NULL,*node_end = NULL,*begin = &(*beginFile),*end = &(*endFile); while(getNode(begin,end,"class",node_start,node_end)) { //process information (I need node_start and node_end here) }
Thanks in advance




Reply With Quote
