I was trying to understand this function. Will the following function return the sum of ASCII values of characters in the string url?
int map(char* url) {
    int key;
    memcpy(key, url, sizeof(int));
    return key;
}
I was trying to understand this function. Will the following function return the sum of ASCII values of characters in the string url?
int map(char* url) {
    int key;
    memcpy(key, url, sizeof(int));
    return key;
}
 
    
    No. I will simply copy bytes from url into key. Enough to fill it.
Now the first sizeof(int) bytes of url can be reinterpreted as an integer.
It seems like a very basic way to generate numeric keys from strings.
 
    
    No, It won't return the sum, it will copy ASCII values of 2 characters of url to key if size of int is 2, otherwise it will copy ASCII values of 4 characters of url.
