Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

How to call a function pointer to function pointer ?

Programming languages, Coding, Executables, Package Creation, and Scripting.
Message
Author
Hadi_Lovelorn
Posts: 51
Joined: 2022-05-02 23:12
Been thanked: 1 time

Re: How to call a function pointer to function pointer ?

#21 Post by Hadi_Lovelorn »

Aki

Hello Sir

It is answered in some way and Thank You ( And used in my code but if some one answer another way as I'm writing IN THIS POST , I will be glad ) , I called the function pointer to function pointer as :

Code: Select all

(*mult)((*add)(num3), num3)
And compiler gave error that (*add) is undeclared , So I called like this for testing :

Code: Select all

(*mult)(int (*add)(num3), num3)
But it gave another error as I wrote in My first post .... It so clear !!

I tried also to define mult as (**mult) to be a nested pointer that points to (*add ) but it didn't work too .... The reason is so clear as I wrote SEVERAL times , Compilers sees (*add) as a local variable ( as parameter of (*mult) , and can't be accessed from outside ....... I'm writing so clear ! So I asked My question and repeated the procedure several times ........ You suggested to define another function pointer as int (*a) in Your First Code and I defined another function pointer as int (*add) and it works But the remain question is : Is there any way to call (*mult) "without" another function pointer defined as another parameter ? Because I saw some experts define a function pointer and another function pointer which takes another function pointer and call it one and also without another defining of function pointer as another parameter if I'm wrong I'm sorry . You said You are not expert , But I see You Know C Programming Language and You can Write Code , And I took My answer ...... Also I'm not an amateur programmer as You can see it in My book :

https://fa.wikibooks.org/wiki/%D8%B2%D8 ... 8%B1_break

https://fa.wikibooks.org/wiki/%D8%B2%D8 ... 8%A8%D8%B9

And Also No , This doesn't relate to My question But pointer functions are fundamental element in C Language and are used in many codes ( If You read source code of expert C tools in Linux You can see them in The Source Code ) and My code doesn't work accidentally ! An Int * is NOT a pointer that refers to int ! It's by integer pointer type , You CAN'T use an int returning varuable as returning of an int * function , Because they are not from same type ....... It's an Integer Pointer and differs from an Integer ........ And They Are used in Simulating of Object-Orientation in C Language as I wrote ..........

And Thank You for Your Help ...... But if some one is an amateur programmer of a very high level language like python why even he would answer repeatedly to a topic ? Nested Functions are not standard C code ( Only a GCC and LLVM and TCC extension ) , And there's NOTING in the name of nested function call !! That's ONYL a recursive function he wrote ....... AND Nested Ponters ARE Pointers to Pointer and Pointers to Pointers to Pointer etc ...... And if he doesn't know what it means to be local as I wrote in My previous posts and ALSO in this post and many other area of programming , Why even he insist to answer what he doesn't know ?

IF ANY THING IS Unclear JUST read THIS POS , SEVERAL TIMES ....... Everything is CLEAR ........

User avatar
sunrat
Administrator
Administrator
Posts: 6458
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 116 times
Been thanked: 472 times

Re: How to call a function pointer to function pointer ?

#22 Post by sunrat »

@Hadi_Lovelorn Don't be rude to people trying to help. Maybe they are not as smart or knowledgable as you, but doesn't mean their input is not valuable. Sometimes the wrong advice can lead to the correct answer.
There's an old saying - "You get more bees with honey than with vinegar".
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

Aki
Global Moderator
Global Moderator
Posts: 2925
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 72 times
Been thanked: 400 times

Re: How to call a function pointer to function pointer ?

#23 Post by Aki »

Hadi_Lovelorn wrote: 2022-08-29 02:07 [..] Everything is CLEAR ........ [...]
@Hadi_Lovelorn: I'm happy to hear this from you. Good luck for your adventures in the world of C language and its pointers.
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

LE_746F6D617A7A69
Posts: 932
Joined: 2020-05-03 14:16
Has thanked: 7 times
Been thanked: 65 times

Re: How to call a function pointer to function pointer ?

#24 Post by LE_746F6D617A7A69 »

Aki wrote: 2022-08-28 22:24 (...) a function that "calls itself" is a possible case of "nested call" (...)
Not really.
We have to distinguish syntax from actual code.
C (and many other languages) allow to simplify the syntax by using a function call in place of regular function arguments - but this is not a 'nesting' of code - this is only a syntax 'quirk' (which causes many problems, especially in debugging, btw)

The resulting code is resolved to a series of function calls (like in my previous post) -> the compiler will use (hidden) temporary variables for keeping the return values from function calls (used as function arguments) and the target function call will be realised by using those temp. vars - no even implied nesting.

Recursion is an effect of using a nested function call, that is, when the function calls itself.
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed

Hadi_Lovelorn
Posts: 51
Joined: 2022-05-02 23:12
Been thanked: 1 time

Re: How to call a function pointer to function pointer ?

#25 Post by Hadi_Lovelorn »

sunrat

Hello Sir

I have nothing to say except a quote ! and since You called me the rude one , Also I have a quote from a " guy " for readers :

"don't believe your eyes and ears , what you're seeing is not what's happening'" !!

LE_746F6D617A7A69
Posts: 932
Joined: 2020-05-03 14:16
Has thanked: 7 times
Been thanked: 65 times

Re: How to call a function pointer to function pointer ?

#26 Post by LE_746F6D617A7A69 »

Quoting myself:
LE_746F6D617A7A69 wrote: 2022-08-29 20:47 (...)
Recursion is an effect of using a nested function call, that is, when the function calls itself.
Since I'm still unable to "think in english" (but I'm trying ;) ), my understanding of nested calls is a bit different than in english terminology. A friend of mine have pointed out that I'm probably misinterpreting the term "nested call" - that is, it can mean *any* nested function call, that is, not necessary a case when the function calls itself.
Basically it means, that "a nested function call" is when some function calls some other function and *not* necessarily itself - i.e. when the function calls itself, we have a special case of a nested call, which is also called a "recursive function call", because it means recursion.

So, Mr Aki was partially right, and I was partially wrong ;)

In any case, using function calls in place of argument values for another function call doesn't mean a nested call - it's just variation of a language syntax, just like I've already pointed out.

Regards
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed

Post Reply