The first thing might be to fix all the compilation errors.
It might look like C, but you need a C++ compiler to compile it.
Code:
$ gcc -g bar.c
bar.c: In function ‘successor’:
bar.c:235:5: error: unknown type name ‘rbtNode’; use ‘struct’ keyword to refer to the type
235 | rbtNode *y=NULL;
| ^~~~~~~
| struct
bar.c:238:11: warning: assignment to ‘int *’ from incompatible pointer type ‘struct rbtNode *’ [-Wincompatible-pointer-types]
238 | y=x->left;
| ^
bar.c:239:17: error: request for member ‘right’ in something not a structure or union
239 | while(y->right!=NULL)
| ^~
bar.c:240:18: error: request for member ‘right’ in something not a structure or union
240 | y=y->right;
| ^~
bar.c:244:11: warning: assignment to ‘int *’ from incompatible pointer type ‘struct rbtNode *’ [-Wincompatible-pointer-types]
244 | y=x->right;
| ^
bar.c:245:17: error: request for member ‘left’ in something not a structure or union
245 | while(y->left!=NULL)
| ^~
bar.c:246:18: error: request for member ‘left’ in something not a structure or union
246 | y=y->left;
| ^~
bar.c:248:13: warning: returning ‘int *’ from a function with incompatible return type ‘struct rbtNode *’ [-Wincompatible-pointer-types]
248 | return y;
| ^
$ gcc -xc++ -g bar.c
Does this work?
Insert in order : 30
delete 30
What about this?
Insert in order : 30,60
delete 30
Or this?
Insert in order : 30,60
delete 60
In other words, what is the smallest test case you can find that causes a problem.
When you find one, run that case in the debugger.
Code:
$ gdb -q ./a.out
Reading symbols from ./a.out...
(gdb) b deleteNode
Breakpoint 1 at 0x1d4e: file bar.c, line 327.
(gdb) run
Starting program: ./a.out
[Detaching after vfork from child process 57533]
sh: 1: cls: not found
No Data
Red Black Tree Menu -
Enter your choice :
1:Insert
2:Delete
3:Search
4:Traversal
5:Exit
1
Enter the integer you want to add : 30
[Detaching after vfork from child process 57538]
sh: 1: cls: not found
30(b)
Red Black Tree Menu -
Enter your choice :
1:Insert
2:Delete
3:Search
4:Traversal
5:Exit
2
Enter the integer you want to delete : 30
Breakpoint 1, deleteNode (var=32767) at bar.c:327
327 struct rbtNode* deleteNode(int var){
(gdb) bt
#0 deleteNode (var=32767) at bar.c:327
#1 0x0000555555556130 in main () at bar.c:441
(gdb) s
328 struct rbtNode *x = NULL, *y = NULL, *z;
(gdb)
329 z=root;
(gdb)
331 if((z->left ==NULL ) &&(z->right==NULL) && (z->key==var))
(gdb) p *z
$1 = {key = 30, color = 98 'b', left = 0x0, right = 0x0, parent = 0x0}
When a variable doesn't contain what you expect, or a branch is taken that you don't expect, then you've found a bug.
Whether that bug is in the code, or a bug in your understanding of what the problem is remains to be determined.