Everything works:
#include <stdio.h>
int (* func)(const char * fmt, ...);
int main()
{
func = (void *)0x400420; /* printf pointer */
printf("printf address: %p\n", printf);
func("func() calling\n");
return 0;
}
But this does not work:
#include <stdio.h>
int (* func)(const char * fmt, ...);
int main()
{
func = (void *)0x400420; /* printf pointer */
/* printf("printf address: %p\n", printf); */
func("func() calling\n");
return 0;
}
Whats I am doing wrong? Tell me, please. Can I call printf (or some other function) by its pointer?
In the second example, printf is not linked to your program.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With