です。ハッシュテーブルにはGlibを使用しています。キーから値を更新する必要があります。更新のためのハッシュテーブルへの削除と挿入がない方法がありますか?それはどのように私はこの機能を使用できるかどうハッシュテーブルの更新値は
私はg_hash_table_replace()
gboolean
g_hash_table_replace (GHashTable *hash_table,
gpointer key,
gpointer value);
を見つけましたが、キーからこの更新値です。
は解決:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <glib.h>
GHashTable * hash_operation = NULL;
int main(int argc, char *argv[]) {
char *from;
int gg = 3;
char *a=strdup("32"),*b=strdup("24"),*c=("mübarek");
hash_operation = g_hash_table_new(g_str_hash, g_str_equal);
g_hash_table_insert(hash_operation, a, gg);
from = strdup(g_hash_table_lookup(hash_operation, a));
printf("%s\n",from);
g_hash_table_replace (hash_operation, a,c);
from = strdup(g_hash_table_lookup(hash_operation, a));
printf("%s\n",from);
free(a);
free(b);
free(c);
free(from);
return 0;
}
問題は解決しました。
まさにあなたの問題は何ですか?同様に、なぜその機能を使用できないのですか(試したコードを表示してください)?あるいは、その機能が不適切なのはなぜですか? – hyde