Hello.
You can study function pointers using typeef.
As I studied the usage example, there is a source like below.
What I'm curious about is what is the return data type of the abc function?
And return (test) NULL; why do you write this part like this?
typedef int (*test)(int, char **);
test abc(char *argv)
{
return (test)NULL;
}
int main(int argc, char **argv)
{
test b;
b = abc(argv[1]);
return 0;
}
The return type of abc()
is a function pointer.
More specifically, returns the address of the function with the return type int and int and char** as parameters.
return (test)NULL;
has the same meaning as returnNULL;
.
They don't cast, but they work the same way.
It seems that the author tried to force the casting because he thought that using NULL
as the function address would cause a compilation error.
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
618 Uncaught (inpromise) Error on Electron: An object could not be cloned
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
915 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.