As always appreciate your time and help! Not sure what's going on here, but it's probably something obvious so I thought I'd have someone else take a look.
This is my code. Right now run finds the address of a node with a specified name as a string. Then returns the address of this node object. Sometimes it works fine (mostly) but other runs give me a segmentation fault. Can anyone see why?
class ManipulateArray
{
public:
Node* formArray();
Node* findMemAddress(string);
private:
GetFileInfo g;
};
Node* ManipulateArray::formArray()
{
Node *list = new Node[48];
string null = "*";
for(int i = 0; i<48; i++)
{
for(int j = 0; j<6; j++)
{
string info = g.returnInfo(i,j);
switch(j)
{
case 0:
list[i].setNodeName(info);
break;
case 1:
if(info.compare(null) == 0)
{list[i].getAttachedNode(j) = 0;}
break;
}
}
}
return list;
}
Node* ManipulateArray::findMemAddress(string nodeName)
{
Node* memoryAddress = 0;
Node* temp;
for(int i = 0; i<48; i++)
{
string name = temp[i].getNodeName();
temp = formArray();
if(name.compare(nodeName) == 0)
{
memoryAddress = &temp[i];
break;
}
}
return memoryAddress;
}
int main()
{
ManipulateArray z;
//Node *start;
//Node *finish;
Node* start;
start = z.findMemAddress("F1");
cout << start->getNodeName();
}