solo learn put this question right but answer is wrong WHY SOLO LEARN ?? WHY?
} THIS IS QUESTION IN CHALLENGE , THEY HAVE PUT 42 IS RIGHT ANSWER
BUT IN MY SYSTEM DEV C++ IT IS SHOWING ZERO AS A OUTPUT
Have you run this code in sololearn codeplay yet?
If not then run in sololearn codeplay and see the output...
Question in challenges made by sololearn users so it has the possibility to have a wrong Answer.
"%d" is wrong specifier for sizeof(). It returns an unsigned type (unsigned int or unsigned long/long long, depends on platform) so In C99 you should use "%zu" specifier and in C89 "%lu".
there is no null-check for return of malloc().
d->second is a float ,so sum of expression will be of type float which in printf() is promoted to double. Result is 24.14 but for "%d" specifier you must cast to int which truncates value to 24. When using wrong format specifiers for your types the behavior will be undefined.
There is no way it should be 42? Unless you wrote numbers in reverse order.