Question: I can't figure out why i get this warning if someone could help fix it warning: assignment makes integer from pointer without a cast [-Wint-conversion]

I can't figure out why i get this warning if someone could help fix it

warning: assignment makes integer from pointer without a cast [-Wint-conversion] a = Search(l); //

/**************************************************************************************/

H file:

#ifndef SYMBTAB_H #define SYMBTAB_H

struct SymbTab { char *symbol; int address; struct SymbTab *next; };

struct SymbTab *Insert(char *symbol, int address); struct SymbTab *Search(char *symbol);

#endif

/**************************************************************************************/

C code :

#include /* #include */ #include #include #include #include "symtable.h"

int size = 0; // void Insert(); void Display(); void Delete(); // int Search(char lab[]); // void Modify(); 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.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: printf(" Enter the symbol to be deleted: "); scanf("%s",la); Delete(la); case 5: exit(0); } } while (op < 6);

} /* end of main */

struct SymbTab *first, *last;

// PRE: PTr to character string, POST, PTR to structure new symbol. // Error message and exit if already present. struct SymbTab *Insert(char *symbol, int address) { struct SymbTab *p = first; while (p != NULL) { if (strcmp(p->symbol, symbol) == 0) { printf("ERROR: symbol already present"); exit(1); } p = p->next; } p = malloc(sizeof(struct SymbTab)); p->symbol = strdup(symbol); p->address = address; p->next = NULL; if (size == 0) { first = p; last = p; } else { last->next = p; last = p; } size++; return p; } void Display() { int i; struct SymbTab *p; p = first; printf("\tSYMBOL\t\tADDRESS "); for (i = 0; i < size; i++) { printf("\t%s\t\t%s\t\t%d ",p->symbol, p->address); p = p->next; } } // PRE: PTr to character string, POST, PTR to structure new symbol. // Error message and exit if already present. struct SymbTab *Search(char *symbol) { struct SymbTab *p = first; while (p != NULL) { if (strcmp(p->symbol, symbol) == 0) { return p; } p = p->next; } return NULL; }

// deleted modify

void Delete(char *symbol) { int a; char l[10]; struct SymbTab *p, *q; p = first; a = Search(l); // if (a == 0) printf(" \tSymbol not found "); else { if (strcmp(first->symbol, l) == 0) first = first->next; else if (strcmp(last->symbol, l) == 0) { q = p->next; while (strcmp(q->symbol, l) != 0) { p = p->next; q = q->next; } p->next = NULL; last = p; } else { q = p->next; while (strcmp(q->symbol, 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!