question about read access violations

hi there, i've been having no issues on the first code, when i run the second code, it shows....
Exception thrown: read access violation.
std::_String_alloc<std::_String_base_types<char,std::allocator<char> > >::_Mysize(...) returned 0xFFFFFFFFFFFFFFFF.

i was wondering what happened. because the coding basically are the same.
1
2
3
4
5
6
7
8
9
10
11
12
13
void display() {
	newnode = head;
	while (newnode != nullptr)
	{
		cout << "\t\tID: "<<newnode->id << endl;
		cout <<"\t\tColor: "<< newnode->color << endl;
		cout << "\t\tDescription: "<<newnode->description << endl;
		
		cout << " " << endl;
		
		newnode = newnode->next;
	}
}


below is the one that gives me an error
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  void displayOrder() {
	Onewnode = Ohead;
	while (Onewnode != nullptr)
	{
		cout << "\t\tID: " << Onewnode->itemID << endl;
		cout << "\t\tColor: " << Onewnode->color << endl;
		cout << "\t\tDescription: " << Onewnode->description << endl;


		cout << " " << endl;

		Onewnode = Onewnode->Onext;
	}
}

thanks in advance.
¿why aren't `{O,}newnode' local to the function?

the function seems fine, you screwed up elsewhere.
Topic archived. No new replies allowed.