P
Prakru
Hello,
Can we have a function pointer to printf or any function with variable arguments?
I have tried in Microsoft Visual Studio C++ compiler
but could not compile.
Is this a compiler dependent problem.
If it can't be compiled what are the reasons for it
typedef int (*printf_ptr) (char *str, ...);
int my_printf (char *str, ...)
{
/* and the standard code for accessing var. args using
* va_args, va_start , va_end */
}
int main ()
{
int i = 10;
printf_ptr = printf;
printf_ptr (" i valus is %d",i);
printf_ptr = my_printf;
printf_ptr (" i valus is %d",i);
}
Thanks
Prakru
Can we have a function pointer to printf or any function with variable arguments?
I have tried in Microsoft Visual Studio C++ compiler
but could not compile.
Is this a compiler dependent problem.
If it can't be compiled what are the reasons for it
typedef int (*printf_ptr) (char *str, ...);
int my_printf (char *str, ...)
{
/* and the standard code for accessing var. args using
* va_args, va_start , va_end */
}
int main ()
{
int i = 10;
printf_ptr = printf;
printf_ptr (" i valus is %d",i);
printf_ptr = my_printf;
printf_ptr (" i valus is %d",i);
}
Thanks
Prakru