This is essentially the only portable way to print a function pointer.
size_t i;
int (*ptr_to_main)() = main;
for (i=0; i<sizeof ptr_to_main; i++)
printf("%.2x", ((unsigned char *)&ptr_to_main)[i]);
putchar('\n');
More Related Contents:
- Hide password input on terminal
- Why does malloc initialize the values to 0 in gcc?
- Where is the header file on Linux? Why can’t I find ? [duplicate]
- Working of fork() in linux gcc [duplicate]
- Where is PATH_MAX defined in Linux?
- Why does the C preprocessor interpret the word “linux” as the constant “1”?
- warning: incompatible implicit declaration of built-in function ‘xyz’
- Merge multiple .so shared libraries
- What is the advantage of GCC’s __builtin_expect in if else statements?
- “undefined reference to `pow'” even with math.h and the library link -lm [duplicate]
- Build .so file from .c file using gcc command line
- How Can I debug a C program on Linux?
- How to compile my own glibc C standard library from source and use it?
- Why am I able to perform floating point operations inside a Linux kernel module?
- Disable variable-length automatic arrays in gcc
- How can a shared library (.so) call a function that is implemented in its loader code?
- How to print time difference in accuracy of milliseconds and nanoseconds from C in Linux?
- Why does GCC not warn for unreachable code?
- How can I include a needed C library using GCC?
- Implementation of sizeof operator
- calling assembly function from c
- How to set up a cron job to run an executable every hour?
- Is there a way to get warned about unused functions?
- Building a shared library using gcc on Linux and MinGW on Windows
- Process Linkage Table and Global Offset Table
- Returning struct containing array
- How does GCC behave if passed conflicting compiler flags?
- getrandom syscall in C not found
- argv: Sanitizing wildcards
- & operator optional in function pointer assignment