Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7532479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:27:58+00:00 2026-05-30T05:27:58+00:00

I am trying to write an implementation of HashTable in C and I am

  • 0

I am trying to write an implementation of HashTable in C and I am getting the error of the form “incompatible implicit declaration of function insertnode”,”previous declaration was here).
I am not able to figure out What could be wrong in this code.

Something is breaking where I am calling the insertnode method from the “put” method.

#include<stdlib.h>
#include<stdio.h>
typedef struct list{
  int data;
  struct list *next;
  struct list * prev;
}list;
typedef struct hash_table{
  int size;
  struct  list ** table;
}hash_table;
int main(){
  int hash(int);
  list* insertnode(list*,int);
  void put(hash_table* ,int);
  list* findnode(list*,int);
  list* get(hash_table*,int);
  hash_table* ht = (hash_table *)malloc(sizeof(hash_table));
  ht->table = (list **)malloc(sizeof(list *)*10);
  int a[]={12,22,33,45,56,12,23,444,44,56,23};
  int i=0;
  for(i=0;i<10;i++)
    ht->table[i]=(list *)malloc(sizeof(list));
  for(i=0;i<11;i++){
    list * node=get(ht,a[i]);
    if(node!=NULL)
    put(ht,a[i]);
    else
      printf("DUPLICATE %d",node->data);
  }
}
void put(hash_table* ht,int data){
int index =  hash(data);
//insert at head of ht->table[index]
 (ht->table)[index]=(list *) insertnode((ht->table)[index],data);
}

list* insertnode(list * head,int data){
  list * newhead = (list *)malloc(sizeof(list));
  newhead->data = data;
  newhead->next = head;
  head->prev = newhead;
  newhead->prev = NULL;
    return newhead;
}

int hash(int data){
  return data%10;
}

list* get(hash_table* ht,int data){
  int index = hash(data);
  list *node=findnode((ht->table)[index],data);
  return node;
}

list* findnode(list* head,int data){
  while(head!=NULL){
    if(head->data==data)
      return head;
    head = head->next;
  }
  return NULL;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T05:27:59+00:00Added an answer on May 30, 2026 at 5:27 am

    You declare insertnode inside your main function. That declaration is not visible outside main.

    You then call insertnode inside your put function. At that point, there is no visible declaration of insertnode. As of C99, this is a constraint violation.

    You then define insertnode after the definition of put.

    The solution is to endure that declarations for all your functions are visible when you call them.

    It rarely makes sense to declare functions inside other functions. For a small program like this without recursion, you can just order your definitions so that everything is visible when it’s called. Or you could put separate declarations at the top of the file, before any of your function definitions. (In a larger program, your declarations would be in a .h header file.)

    A function declaration is something like:

    list *insertnode(list*, int);
    

    It makes it possible for the compiler to handle calls to the function.

    A definition includes the block { /* ... */ } that defines what the function does. It also provides a declaration.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a program to test student code against a good implementation.
I am trying write a function that generates simulated data but if the simulated
Trying to write a function to see how often an object exists and give
I am trying to write a function in C++ which takes two 64 bit
I'm trying to write an implementation of a 2-3-4 tree in c++. I'm it's
I'm trying to write my own Mergesort function in the same fashion as C's
I'm trying to write my own implementation of ListSelectionModel and currently I'm stuck while
I am trying to write a small application to use DataNucleus' JDO implementation on
I'm trying to write a simple implementation of a patience sort, using Scala. I've
In short I'm trying to write an AbstractMap implementation and I encountered a syntax

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.