Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Question: Can i use (khash) KHASH_SET_INIT_INT64() for negative values for key . Because i saw in khash header file its using unsigned long int please help me. #172

Open
SSUAMKIETT opened this issue Sep 16, 2023 · 0 comments

Comments

@SSUAMKIETT
Copy link

SSUAMKIETT commented Sep 16, 2023

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "klib/khash.h"

KHASH_SET_INIT_INT64(bin_value)

int counter = 1;
int main() {
khash_t(bin_value) bin_value_pointer = kh_init(bin_value);
FILE
file = fopen("read.txt", "r");
char line[20];
while(fgets(line, sizeof(line), file)) {
int64_t value;
int ret;
if(sscanf(line, "%ld", &value) == 1) {
kh_put(bin_value, bin_value_pointer, value, &ret);
}
}
fclose(file);

FILE* file1 = fopen("check.txt", "r");
while(fgets(line, sizeof(line), file1)) {
    int64_t input;
    int ret;
    if(sscanf(line, "%ld", &input) == 1) {
       if(kh_get(bin_value, bin_value_pointer, input) != kh_end(bin_value_pointer)) {
            printf("matched counter= %d\n", counter++);
        }
    }
}

kh_destroy(bin_value, bin_value_pointer);
fclose(file1);
return 0;

}

i am implement hashSet i wanted to know can i use this for negative value for key please help i am new to the C.

@SSUAMKIETT SSUAMKIETT changed the title Question: Can i use (kthash) KHASH_SET_INIT_INT64() for negative values. Because i saw in kthash header file its using unsigned long int please help me. Question: Can i use (kthash) KHASH_SET_INIT_INT64() for negative values for key . Because i saw in kthash header file its using unsigned long int please help me. Sep 16, 2023
@SSUAMKIETT SSUAMKIETT changed the title Question: Can i use (kthash) KHASH_SET_INIT_INT64() for negative values for key . Because i saw in kthash header file its using unsigned long int please help me. Question: Can i use (khash) KHASH_SET_INIT_INT64() for negative values for key . Because i saw in khash header file its using unsigned long int please help me. Sep 16, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant