32ビットと64ビットの両方のLinuxプラットフォームでC99でint
を変換/キャストする適切な方法は何ですか?size_t
例:
int hash(void * key) {
//...
}
int main (int argc, char * argv[]) {
size_t size = 10;
void * items[size];
//...
void * key = ...;
// Is this the right way to convert the returned int from the hash function
// to a size_t?
size_t key_index = (size_t)hash(key) % size;
void * item = items[key_index];
}