Specifically about the put
function: I've reviewed the answers to this question and followed some of the suggestions e.g. putting an else
condition in the put
function, with no luck.
I still get the above warning at compile time. I suspect there is something else going on in the code to cause it.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hashtable.h"
/* For a given string refered to by the pointer "string",
* calculate the hashcode and update the int "value".
*
* Return 1 if successful, return 0 if unsuccessful.
*/
int main(){
}
int hash(char *string, unsigned long *value) {
value = 0;
if(string == NULL) {
return 0;
}
while(string != NULL) {
*value = *value + *string;
string++;
}
return 1;
}
/* Add the string to the hashtable in the appropriate "bucket".
*
* Return 1 if successful, and 0 if unsuccessful.
*/
int put(char *string, hashtable *h) {
unsigned long hashValue = 0;
int hashcode = hash(string, &hashValue);
int index = hashValue %CAPACITY;
node *head = &head -> next[index];
node *newNode = malloc(sizeof(node));
if(newNode == NULL)
return 0;
else
return 1;
}
/*
* Determine whether the specified string is in the hashtable.
* Return 1 if successful, and 0 if unsuccessful.
*/
int get(char *string, hashtable *h) {
int i = *string;
int newNode;
for(i = 0; i <= newNode; i ++)
if(*string == newNode) {
return 1;
}
return 0;
}