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

  • SEARCH
  • Home
  • 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 7308469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:33:42+00:00 2026-05-28T23:33:42+00:00

I have following typedef declarations in c but confused how I read these declarations.

  • 0

I have following typedef declarations in c but confused how I read these declarations.

   typedef char  *pc;     /* pc is pointer to char                      */
   typedef pc     fpc();  /* fpc is function returning pointer to char  */
   typedef fpc   *pfpc;
   typedef pfpc   fpfpc();
   typedef fpfpc *pfpfpc;
   pfpfpc a[N];

Now for me first two statement is easy to read but really confused after that.

Is there any way to solve(read) such equations?

  • 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-28T23:33:42+00:00Added an answer on May 28, 2026 at 11:33 pm
    typedef char  *pc;     /* pc is pointer to char                      */
    typedef pc     fpc();  /* fpc is function returning pointer to char  */
    

    Good so far. Note that the last typedef can also be written as

    typedef char *fpc();
    

    Next,

    typedef fpc   *pfpc;
    

    declares pfpc as a pointer to fpc. Since we know that fpc is a function returning a pointer to char, then pfpc must be a pointer to a function returning pointer to char, or

    typedef char *(*pfpc)()  
    

    Next we have

    typedef pfpc   fpfpc();
    

    This time, fpfpc is a function returning pfpc. Since we know that pfpc is a pointer to a function returning pointer to char, fpfpc must be a function returning a pointer to a function returning pointer to char, or

    typedef char *(*fpfpc())();
    

    Next, we have

    typedef fpfpc *pfpfpc;
    

    which declares pfpfpc as a pointer to fpfpc. Since we know fpfpc is a function returning a pointer to a function returning pointer to char, pfpfpc must be a pointer to a function returning a pointer to a function returning a pointer to char, or

    typedef char *(*(*pfpfpc)())();
    

    Finally, we have an an N-element array of pfpfpc

    pfpfpc a[N];
    

    Since we know pfpfpc is a pointer to a function returning pointers to functions returning pointers to char, then a must be an N-element array of pointers to functions returning pointers to functions returning pointers to char:

    char *(*(*a[N])())();
    

    The main rule to remember for reading and writing hairy declarations is that [] and () have higher precedence than *, so

    *a[]       -- is an array of pointer
    (*a)[]     -- is a pointer to an array
    *f()       -- is a function returning a pointer
    (*f)()     -- is a pointer to a function
    

    and the whole thing is broken down as

              a                -- a
              a[N]             -- is an N-element array
             *a[N]             -- of pointers
            (*a[N])()          -- to functions
           *(*a[N])()          -- returning pointer
          (*(*a[N])())()       -- to function
         *(*(*a[N])())()       -- returning pointer
    char *(*(*a[N])())()       -- to char
    

    Going the other way, we have

             pfpfpc              -- is a synonym for
           *  fpfpc              -- is a synonym for
           *   pfpc()            -- is a synonym for
           *(* fpc)()            -- is a synonym for
           *(*pc())()            -- is a synonym for
    char *(*(* )())()
    

    The last step isn’t terribly intuitive, I’ll admit.

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

Sidebar

Related Questions

I have declared the following struct: typedef struct _RECOGNITIONRESULT { int begin_time_ms, end_time_ms; char*
I have the following C code: typedef void (*mycallback) (char buf[128]); void take_callback(mycallback cb)
Let's say I have the following code: typedef std::function<void ()> func_type; void some_func() {
I have the following typedef function prototype: typedef void (*sa_sigaction_t)(int, siginfo_t *, void *);
I have the following for my HashTable structure: typedef char *HashKey; typedef int HashValue;
Suppose I have the following: typedef enum functionType {ln, sin, sqrt} functionType; NSArray *functions
I came across the following weird chunk of code.Imagine you have the following typedef:
I have the following C++ code: typedef istream_iterator<string> isi; // (1) vector<string> lineas(isi(cin), isi());
I have created the following C library for reading an image: typedef struct {
I have C header file containing the following type definition: // example.h typedef struct

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.