0

#include "hash_tables.h"

/**

  • hash_table_create -> create hash table

  • @size: sixe of the hash table

  • Return: the new hash table
    */
    hash_table_t *hash_table_create(unsigned long int size)
    {
    hash_table_t *HashTable;

     HashTable = malloc(sizeof(hash_table_t));                                                                                                             
     if (HashTable == NULL)                                                                                                                                
             return (NULL);                                                                                                                                
    
     HashTable->size = size;                                                                                                                               
     /*allocating memory for array*/                                                                                                                       
     HashTable->array = malloc(sizeof(hash_node_t *) * size);                                                                                              
     if (HashTable->array == NULL)                                                                                                                         
     {                                                                                                                                                     
             free(HashTable->array);                                                                                                                       
             return (NULL);                                                                                                                                
     }                                                                                                                                                     
     return (HashTable);                                                                                                                                   
    

}

JuanR
  • 7,405
  • 1
  • 19
  • 30
  • 2
    Do you have a `main` function? If so, please post it, if not, then the error message is complaining that you need one. – Dan Getz Oct 20 '22 at 21:58

1 Answers1

0

I don't know whether you show the whole error, or just a part of it. From what I tried on ideone.com, when you try to compile code without any main function's definition, you receive the following error:

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status

See https://ideone.com/qNVMAk

The compilation goes fine if you add a main function's definition, for example that one:

int main (void) {
    return 0;
}

So, I guess you need to add some main function's definition to the code you try to compile.

For details, you can see this similar question: Undefined reference to main - collect2: ld returned 1 exit status

user20276305
  • 95
  • 1
  • 7