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 7926157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:38:35+00:00 2026-06-03T18:38:35+00:00

I was wondering if it is possible in C (89/90) to chain function calls,

  • 0

I was wondering if it is possible in C (89/90) to chain function calls, and where it is defined in the C spec. I assume this isn’t possible since a google search reveals no mention of it.

I thought of this because of a related conversation with a friend of mine where he told me that given a function returning a struct, you cannot perform any operations on said struct within the same statement; instead, you have to assign the result of the function to a variable, and then manipulate the struct via the variable instead of directly from the function result itself. This leads me to believe that you can’t chain functions either, but I can’t seem to find these limitations discussed in the spec.

Edit : Sorry, I should have been specific on the return value. Assuming the function returns a function pointer, is it possible to dereference and call the result within the same statement, in fluent fashion?

For example, assuming getFunc returns a function pointer :

(*getFunc(getFuncParam))(otherFuncParam)

Or in the struct case, assuming a struct with an int member called count:

funcReturnsStruct(param).count++
  • 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-06-03T18:38:37+00:00Added an answer on June 3, 2026 at 6:38 pm

    Here’s what function chaining looks like in C:

    post_process(process(pre_process(data)));
    

    Obviously, your friend is wrong. As long as the functions cooperate by accepting and returning the same type of value you can chain the calls all you like.

    Contrast this with something like

    data.pre_process().process().post_process();
    

    The big difference is that in C (which has no encapsulation, hence no classes) functions have center stage while in more modern OO languages it’s objects that get more attention.

    Update: Sure it’s possible to chain no matter what each function might return. For example:

    int increase(int x) {
        return x + 1;
    }
    
    typedef int (*increase_fp)(int);
    
    increase_fp get_increase() {
        return increase;
    }
    
    int main(void) {
        printf("%d", get_increase()(1));
        return 0;
    }
    

    See it in action.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if its possible to use the Google maps IFRAME code to
I'm wondering if its possible to make a list like this: Or should I
I'm wondering if its possible to do this. The issue being that im trying
This may be impossible, but I was wondering if it was possible to keep
Was wondering is this possible in .htaccess? I'm currently caching .js, .css and all
I'm wondering if is possible to convert this HQL query into a criteria api
I was wondering if its possible to parse strings to defined values for uint.
I was wondering ( if possible ) if there was a program/tool/utility that when
Just toying with the SDK and I was wondering if possible a UITouch event
I was wondering - is it possible to change files that are stored on

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.