[Solved] Call function use pointer

First of all: Your functions void my_int_func(int x) and void my_int_func2(int y) do not return anything (return type void). They just prompt the input parameters to stdout. What you probably want is something like that #include <iostream> using namespace std; int my_int_func(int x) { return x; } int my_int_func2(int x) { return x; } void … Read more

[Solved] How to Implement stack by function pointer and how to use it [closed]

No, function members cannot be declared in C structs (only in C++). The convention is to pass the struct pointer as the first argument in the functions when doing object oriented programming. Also, C++ really does the same thing, the “this” pointer is passed as the first argument, it is just hidden. struct stack{ int[10] … Read more

[Solved] Decoding declaration(a combination of array and function pointers) in C [closed]

That code is not a declaration, but it can be interpreted as an expression. (*I_dont_know())[(int) ((*ptr))] Call the function I_dont_know with no arguments. This function returns a pointer to something. Dereference the returned pointer to get some object. Meanwhile, dereference the value of ptr and cast it to an int value. Then pass that int … Read more

[Solved] Function Pointers stored in global variables get set to 0 when entering function, and get back to previous state when exiting function

if you write in header file static PFNGLGETERRORPROC glGetError; every c/cpp have own private copy of glGetError and it not conflict with other because it static – so different cpp files use different versions of glGetError – in one cpp unit you init one version and it !=0, when you enter to another cpp unit … Read more

[Solved] expected ‘void (**)(void *, const char *)’ but argument is of type ‘void (*)(void *, const char *)

It is pretty wonky, it wants to return the default error handler. So you have to pass a pointer to a variable. Like this (untested): xmlGenericErrorFunc handler; initGenericErrorDefaultFunc(&handler); If I understand your intentions properly, this is not the function you actually want to use to suppress errors. Use xmlSetGenericErrorFunc() instead. You can use initGenericErrorDefaultFunc() to … Read more

[Solved] Why exactly can’t function pointers be implicitly converted?

There are implicit and explicit conversions. A cast is always an explicit conversion and uses the (type) cast operator. C has quite decent type safety when it comes to pointers. Apart from the special case of null pointer conversions, the only implicit pointer conversion allowed is between an object pointer and a pointer to void. … Read more