Access violation-error

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
else if (!strcmp("CourseDetails",part2.c_str()))
				{
					

					getline(ss2, part2, ','); // get the cours number
					int num=0;
					num = atoi(part2.c_str()); // convert string to int

					getline(ss2, part2, ','); // get the Department
					Cours_ptr_TMP = NULL; // initialize the ptr
					
					
					Cours* head__ = NULL;
					while ( Department_Ptr_TMP != NULL )
					{
						if (!strcmp ( Department_Ptr_TMP->get_m_Department_name() , part2.c_str() ) ) // if equal go in means we find the Department
						{
							Cours* Cours_ptr_TMP_TMP = new Cours;

							Cours_ptr_TMP_TMP->set_m_cours_number(num); //tmptmp as tmp, tmp as head
									
							getline(ss2, part2, ',');
							Cours_ptr_TMP_TMP->set_m_number_of_points(atoi(part2.c_str())) ; // set number of points to the cours

							getline(ss2, part2, ',');
							Cours_ptr_TMP_TMP->set_m_cours_name(part2.c_str()); // set cours name

							Cours_ptr_TMP_TMP->Next_Cours = head__;
							head__ = Cours_ptr_TMP_TMP;

							// i was here in the part of work which i pharser the course line details and after that assing the list to the list i neet in the department

							cout<<1;
						}
  
						Department_Ptr_TMP = Department_Ptr_TMP->Next_Department; // advance the pointer
					}
					Department_Ptr_TMP->m_PTR_2_Cours_Name_List = head__;
				}


I'm getting error "Unhandled exception at 0x003ce194 in reference counting.exe: 0xC0000005: Access violation writing location 0x00000004."

what can I do ? I need to make a list and I'm falling at the line

Department_Ptr_TMP->m_PTR_2_Cours_Name_List = head__;

thanks in advance...
It may be that Department_Ptr_TMP is NULL, it may be that m_PTR_2_Cours_Name_List is NULL. Make sure you always test for NULL!
Topic archived. No new replies allowed.