clibs / hash Goto Github PK
View Code? Open in Web Editor NEWC hash implementation based on khash
C hash implementation based on khash
a hash tabel contains a key that value="1234567" and I check the hash table with key value = "12345678",
hash table does not return null but a pointer to the value of key value = "1234567".
sorry,i'm a newbie,Who can tell me the problem of following code?
//code
int main(int args,char *argv[])
{
hash_t *hash_tab = NULL;
char k[32] = {0};
char cont[8] = {0};
int value = 0;
hash_tab = hash_new();
do {
printf("input key\n");
scanf("%s",k);
printf("input value\n");
scanf("%d",&value);
if(!hash_has(hash_tab,k))
hash_set(hash_tab,k,&value);
printf("conitinue add key? [y|n]\n");
scanf("%s",cont);
}while(!strcasecmp("y",cont));
hash_each(hash_tab, {
printf("%s: %d\n", key, *(int *) val);
});
hash_free(hash_tab);
}
//exe:
./test
input key
li
input value
2
conitinue add key? [y|n]
y
input key
yan
input value
3
conitinue add key? [y|n]
n
yan: 3
yan: 3
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.