Hi,

I have been trying to wrap my head around this problem for a while now and I just can't figure it out. I've included the code that is involved with the runtime error. Basically, I have a pointer that points to another pointer. Action points to an array of I've implemented them in this fashion:

//I included the define attributes part too
        
       #define GET_NODE_ATTRIBUTES(FOR_NODE)\
	attr_map = FOR_NODE.attributes();\
	for ( k = 0; k < attr_map.count(); k++) {\
		attr_node = attr_map.item(k);\
		node_name = attr_node.nodeName();\
		val_str = attr_node.nodeValue();		
	
        Group*  m_groups = new Group[m_numGroups];
        Action** m_events = new Action*[m_numGroups];

        // Some code inbetween here

        QDomNodeList cur_childNodes, me_childNodes;
	QDomNode cur_node, me_argNode;
	string mbt, sub_mbt;
	size_t pos1, pos2;
	
	Action curME_ptr;
	Argument* curArgs_ptr;

        //get the show's metaevents
        cur_node = node.namedItem("metaevents");
	cout << cur_node.nodeName().toStdString() << endl;
	cur_childNodes = node.childNodes();
	m_groups[i].putMEs( cur_childNodes.count() );


        for (i =  0; i < m_numGroups; i++)
	m_events[i] = new Action[cur_childNodes.count()];
       // where cur_childNodes.count() is the number of arguments

I should (if I did that part right) have a pointer to a pointer m_events[j] and the program doesn't have problem running to there. It's when I try to create a cursor pointer that I run into problems. I have tried getting rid of the cursor pointer all together but I still have problems running it. I'm also using Qt, though I don't think that's the issue.

for (j = 0; j < cur_childNodes.count(); j++ ) 
		{
		    cur_node = cur_childNodes.item(j);
		
		    curME_ptr = (*m_events)[j];

		    GET_NODE_ATTRIBUTES(cur_node)
			if (node_name == "type") 
			{
			        curME_ptr.putType(val_str.toAscii().data()); 
				cout << curME_ptr.getType() << endl;
			}
                  // the computer seems to call this first which is fine
			else if (node_name == "location") 
			{ 
				 mbt = val_str.toAscii().data();
				 pos1 = mbt.find_first_of(":");
				 sub_mbt = mbt.substr(0, pos1);
				curME_ptr.putName(sub_mbt); 
                                //program freezes after this line
                                pos2 = mbt.find_last_of(':');
			        sub_mbt = mbt.substr(pos1, (pos2 - pos1));
				curME_ptr.putMinute(atoi(sub_mbt.c_str()));				
				curME_ptr.putSecond( atoi( (mbt.substr(++pos2)).c_str()));
                         }
                     }

putName refers to a method in class Action that put a string into a private string variable.

class RMSAction
{
private:
      string  name;
public:
       void	putMeasure(string n) {name = n;}
}

I have tried a variety of ideas but perhaps I'm viewing this wrong? I have tried to find documentation on the web about cursor pointers to pointers of pointers but I haven't really come across any information. Also, the code that I'm working on is being updated, so I'm also wondering if this is just a C thing and there a better way of doing this?

Any help would be appreciated.
Thanks.

Recommended Answers

All 2 Replies

Nevermind I figured it out.
I had it right except for a simple syntax error.

What is it "cursor pointer"? I know cursor:pointer pair in CSS, but it's the other story...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.