שגיאת הרצה ב-++C
בזמן הרצת התוכנית אני מקבל הודעת שגיאה כזו -
בזמן הרצת התוכנית אני מקבל הודעת שגיאה כזו -
Thread stopped at * Fault: access violation at 0x4010b1: read of address 0x0
כאשר * הוא שם הכונן והקובץ זו התוכנית:struct Tree { int Key; Tree *p; Tree *Left; Tree *Right; }; void TreeInsert(Tree **root,Tree **z) { Tree *x,*y; y = NULL; x = *root; while (x != NULL) { y = x; if ((*z) -> Key < x -> Key) x = x -> Left; else x = x -> Right; } (*z) -> p = y; if (y == NULL) root = z; else if ((*z) -> Key < x -> Key) y -> Left = *z; else y -> Right = *z; } void PrintTree(Tree *ptr) { if (ptr != NULL) { PrintTree(ptr -> Left); cout << (ptr -> Key); PrintTree(ptr -> Right); } } void main() { Tree *r,*z; r = new Tree; z = new Tree; r -> Key = 5; r -> p = NULL; r -> Left = NULL; r -> Right = NULL; z -> Key = 10; z -> p = NULL; z -> Left = NULL; z -> Right = NULL; TreeInsert(&r,&z); } מה אני עושה לא בסדר?