Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6806287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:41:31+00:00 2026-05-26T19:41:31+00:00

Imagine a function myFunctionA with the parameter double and int: myFunctionA (double, int); This

  • 0

Imagine a function myFunctionA with the parameter double and int:

myFunctionA (double, int);

This function should return a function pointer:

char (*myPointer)();

How do I declare this function in C?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:41:32+00:00Added an answer on May 26, 2026 at 7:41 pm
    void (*fun(double, int))();
    

    According to the right-left-rule, fun is a function of double, int returning a pointer to a function with uncertain parameters returning void.

    EDIT: This is another link to that rule.

    EDIT 2: This version is only for the sake of compactness and for showing that it really can be done.

    It is indeed useful to use a typedef here. But not to the pointer, but to the function type itself.

    Why? Because it is possible to use it as a kind of prototype then and so ensure that the functions do really match. And because the identity as a pointer remains visible.

    So a good solution would be

    typedef char specialfunc();
    specialfunc * myFunction( double, int );
    
    specialfunc specfunc1; // this ensures that the next function remains untampered
    char specfunc1() {
        return 'A';
    }
    
    specialfunc specfunc2; // this ensures that the next function remains untampered
    // here I obediently changed char to int -> compiler throws error thanks to the line above.
    int specfunc2() {
        return 'B';
    }
    
    specialfunc * myFunction( double value, int threshold)
    {
        if (value > threshold) {
            return specfunc1;
        } else {
            return specfunc2;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets imagine function like this: function foo(x) { x += '+'; return x; }
Imagine this function: void SoundManager::playSource(ALuint sourceID, float offset) { alSourceStop(sourceID); ALint iTotal = 0;
Imagine I have a template function like this: template<typename Iterator> void myfunc(Iterator a, typename
Imagine I have this code: var myFunc1 = function(event) { alert(1); } var myFunc2
Let's imagine that we have object Animal $.Animal = function(options) { this.defaults = {
Imagine there is a newtype declaration: newtype T = T Int This declaration is
Let's imagine something like this: class MyTable extends Doctrine_Table { public function construct() {
Imagine such situation that I have a function like this: Object f() { Object
Imagine I have a list like this: a = [1,2,3,4,5,6] Using a lambda function,
Imagine I run this: $.ajax({ type: 'POST', url: '/ajax/watch.php', data: {'watch':'aukcia', 'id':aukciaID}, complete: function(responseText){

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.