g_hash_table problem
- From: Kuang-Chun Cheng <kccheng openate com>
- To: gnome-devel-list gnome org
- Subject: g_hash_table problem
- Date: Mon, 28 Jun 2004 18:15:40 +0800
Hi,
Why the following code not working ?
The result will be "KEY aaa NOT FOUND".
The key can't be found if I use buf[], and
it can be found if I search "aaa" ???
Thanks.
----
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <glib.h>
int main (int argc, char *argv[])
{
char buf[1024];
GHashTable *htab;
htab = g_hash_table_new(NULL, NULL);
g_hash_table_insert(htab, "aaa", NULL);
strcpy(buf, "aaa");
if (g_hash_table_lookup(htab, buf)) {
printf("KEY %s FOUND\n", buf);
} else {
printf("KEY %s NOT FOUND\n", buf);
}
g_hash_table_destroy(htab);
exit(0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]