#define HASHSIZE 12
#define NULL_KEY -111
typedef struct {
int *arr;
int size;
}Hashmap;
int initHash(Hashmap *hashmap);
void print(Hashmap *hashmap);
int main(void) {
#Hashmap * hashmap=(Hashmap *)malloc(sizeof(Hashmap));
#int flag;
Hashmap * hashmap=NULL; #malloc函數分配內存失敗返回NULL指針
int flag;
hashmap=(Hashmap *)malloc(sizeof(Hashmap));
if(NULL==hashmap) {
exit (1) ;
}
if(flag == 0)
print(hashmap);
free(hashmap);
hashmap=NULL;
return 0;
}
int initHash(Hashmap *hashmap) {
int i;
hashmap->size=HASHSIZE;
hashmap->arr=(int *)malloc(HASHSIZE*sizeof(int));
for(i=0;i<HASHSIZE;++i) {
*(hashmap->arr+i)=NULL_KEY;
}
return 0;
}
void print(Hashmap *hashmap) {
int i;
for(i=0;i<HASHSIZE;++i) {
printf ("%d\t",*(hashmap->arr+i));
}
}