Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //explanation : https://www.facebook.com/groups/arabcpp/permalink/759109994119678/?comment_id=759169170780427&offset=0&total_comments=12
- // undefined behaviour (works on gcc)
- #include <windows.h>
- #include <stdio.h>
- typedef double (*cos_t)(double);
- int cos_count = 0;
- double cos(double zawya)
- {
- cos_count++;
- HINSTANCE c_runtime = LoadLibrary("msvcrt.dll"); // microsoft visual c runtime
- cos_t cos_ptr = (cos_t)GetProcAddress(c_runtime, "cos");
- return cos_ptr(zawya);
- }
- int main (void)
- {
- cos(2);
- cos(2);
- cos(2);
- printf("%d cosine functions were called", cos_count);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement