Question
How would I remove the instance of label in the Delete() function, and add the user input to main(). I can't seem to figure it
How would I remove the instance of "label" in the Delete() function, and add the user input to main().
I can't seem to figure it out.. to my knowledge I need the Delete() function, but I cannot have any "label" occurrences.
I'm only uploading the sections I need help in, since the rest of the code does in fact work and these two are the only things i cant get to work
/**************************************************/
C file > int main(void) { int op; // removed y, because it was connected to "label" char la[10]; do { printf(" \tSYMBOL TABLE IMPLEMENTATION "); printf(" \t1.INSERT \t2.DISPLAY \t3.DELETE \t4.SEARCH \t5.MODIFY \t6.END "); printf(" \tEnter your option : "); scanf("%d", &op); switch (op) { case 1: printf(" Enter the symbol"); scanf("%d", &op); int address; printf("Enter the address: "); scanf("%d", &address); Insert(la,address); printf(" Smbol inserted "); break; case 2: Display(); break; case 3: printf(" Enter the symbol to be searched: "); scanf("%s", la); struct SymbTab *result = Search(la); printf(" Search Result: "); if (result != NULL) { printf(" The symbol is present "); }else { printf(" The symbol is present "); } break; case 4: exit(0); } } while (op < 6);
} /* end of main */
struct SymbTab *first, *last;
void Delete() { int a; char l[10]; struct SymbTab *p, *q; p = first; printf(" \tEnter the label to be deleted : "); scanf("%s", l); a = Search(l); // if (a == 0) printf(" \tLabel not found "); else { if (strcmp(first->label, l) == 0) first = first->next; else if (strcmp(last->label, l) == 0) { q = p->next; while (strcmp(q->label, l) != 0) { p = p->next; q = q->next; } p->next = NULL; last = p; } else { q = p->next; while (strcmp(q->label, l) != 0) { p = p->next; q = q->next; } p->next = q->next; } size--; printf(" \tAfter Deletion: "); Display(); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started