question about declaration - pointers

Discussion in 'C Programming' started by jeniffer, Dec 27, 2007.

  1. jeniffer

    jeniffer Guest

    What does the following declare?
    char*(*(*x)(void))[];

    How to judge these type of questions? I am confused :(
    jeniffer, Dec 27, 2007
    #1
    1. Advertising

  2. "jeniffer" <> schrieb im Newsbeitrag
    news:...
    > What does the following declare?
    > char*(*(*x)(void))[];
    >
    > How to judge these type of questions? I am confused :(

    WiINcdecl says:
    declare x as pointer to function (void) returning pointer to array of
    pointer to char

    In General you'd have to work this from the inside (the inner most part,
    here thr x) to the outside, alternatiting left and right

    *x is a pointer
    () to a function
    (void) that takes no arguments
    * and returns a pointer
    [] to an array
    char * of pointers to char

    Bye, Jojo
    Joachim Schmitz, Dec 27, 2007
    #2
    1. Advertising

  3. jeniffer

    army1987 Guest

    jeniffer wrote:

    > What does the following declare?
    > char*(*(*x)(void))[];

    A pointer to a function taking no arguments, and returning a pointer to an
    array of unspecified length of pointers to char.

    > How to judge these type of questions? I am confused :(

    See http://www.c-faq.com/ question 1.21, and remind to whoever wrote that
    stuff that typedef exists. :)


    --
    Army1987
    army1987, Dec 27, 2007
    #3
  4. jeniffer said:

    > What does the following declare?
    > char*(*(*x)(void))[];


    Others have already answered this part of your question.

    > How to judge these type of questions? I am confused :(


    Judge these types of questions harshly. The question you show is
    practically meaningless, because it tests a skill that is only needed when
    deconstructing and rewriting badly-written code.

    --
    Richard Heathfield <http://www.cpax.org.uk>
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999
    Richard Heathfield, Dec 27, 2007
    #4
  5. jeniffer

    jeniffer Guest

    On Dec 27, 4:03 pm, "Joachim Schmitz" <>
    wrote:
    > "jeniffer" <> schrieb im Newsbeitragnews:...> What does the following declare?
    > > char*(*(*x)(void))[];

    >
    > > How to judge these type of questions? I am confused :(

    >
    > WiINcdecl says:
    > declare x as pointer to function (void) returning pointer to array of
    > pointer to char
    >
    > In General you'd have to work this from the inside (the inner most part,
    > here thr x) to the outside, alternatiting left and right
    >
    > *x is a pointer
    > () to a function
    > (void) that takes no arguments
    > * and returns a pointer
    > [] to an array
    > char * of pointers to char
    >
    > Bye, Jojo



    Thanks a lot for the answer!
    jeniffer, Dec 27, 2007
    #5
  6. jeniffer

    Guest

    On Dec 27, 1:23 pm, Richard Heathfield <> wrote:
    > jeniffer said:
    >
    > > What does the following declare?
    > > char*(*(*x)(void))[];

    >
    > Others have already answered this part of your question.
    >
    > > How to judge these type of questions? I am confused :(

    >
    > Judge these types of questions harshly. The question you show is
    > practically meaningless, because it tests a skill that is only needed when
    > deconstructing and rewriting badly-written code.


    What if you are writing a C compiler or something similar?
    Shall the compiler error because the programmer used a 'bad' data
    type?
    , Dec 27, 2007
    #6
  7. said:

    > On Dec 27, 1:23 pm, Richard Heathfield <> wrote:
    >> jeniffer said:
    >>
    >> > What does the following declare?
    >> > char*(*(*x)(void))[];

    >>
    >> Others have already answered this part of your question.
    >>
    >> > How to judge these type of questions? I am confused :(

    >>
    >> Judge these types of questions harshly. The question you show is
    >> practically meaningless, because it tests a skill that is only needed
    >> when deconstructing and rewriting badly-written code.

    >
    > What if you are writing a C compiler or something similar?


    What if you are? :)

    > Shall the compiler error because the programmer used a 'bad' data
    > type?


    The compiler should diagnose syntax errors and constraint violations, but
    the above is not either of those. It follows the rules of the grammar, and
    so the compiler writer will be able to deal with it simply by implementing
    the grammar, which is a darn sight easier than decoding the above. (But
    yes, okay, you're right - a compiler writer ought to be able to decode
    such expressions by hand, even if it's only for testing purposes.)

    --
    Richard Heathfield <http://www.cpax.org.uk>
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999
    Richard Heathfield, Dec 27, 2007
    #7
  8. jeniffer

    Ben Pfaff Guest

    writes:

    > On Dec 27, 1:23 pm, Richard Heathfield <> wrote:
    >> jeniffer said:
    >>
    >> > What does the following declare?
    >> > char*(*(*x)(void))[];

    >>
    >> Others have already answered this part of your question.
    >>
    >> > How to judge these type of questions? I am confused :(

    >>
    >> Judge these types of questions harshly. The question you show is
    >> practically meaningless, because it tests a skill that is only needed when
    >> deconstructing and rewriting badly-written code.

    >
    > What if you are writing a C compiler or something similar?


    I surely would not mind if the C compiler diagnosed the above
    similar to:

    foo.c:6: warning: complicated type declarations are difficult to understand
    --
    char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
    ={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa67f6aaa,0xaa9aa9f6,0x11f6},*p
    =b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
    2:{i++;if(i)break;else default:continue;if(0)case 1:putchar(a[i&15]);break;}}}
    Ben Pfaff, Dec 27, 2007
    #8
  9. jeniffer

    Dann Corbit Guest

    "jeniffer" <> wrote in message
    news:...
    > What does the following declare?
    > char*(*(*x)(void))[];
    >
    > How to judge these type of questions? I am confused :(


    E:\>cdecl
    Type `help' or `?' for help
    cdecl> explain char*(*(*x)(void))[];
    declare x as pointer to function (void) returning pointer to array of
    pointer to char
    cdecl>

    Look on the net for cdecl.zip

    There are other distributions as well (e.g. in BSD code base)



    --
    Posted via a free Usenet account from http://www.teranews.com
    Dann Corbit, Dec 28, 2007
    #9
  10. Dann Corbit said:

    <snip>

    > Look on the net for cdecl.zip


    I have done so. I even found it. The zip file was corrupted...

    > There are other distributions as well (e.g. in BSD code base)


    ....so I found a version written by Graham Ross, supposedly converted to
    ANSI C by David Wolverton, which didn't compile. Once I got it to compile
    (by removing features), it didn't link. Once I got it to link (by removing
    more features), it didn't run (segfaulted straight away).

    The cdecl functionality is a perfectly good example of code that *could* be
    written in solid, clc-conforming ISO C code. And who knows? Perhaps it has
    been. If so, where may it be found? And if not, well, I'll add it to my
    to-do list.

    --
    Richard Heathfield <http://www.cpax.org.uk>
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999
    Richard Heathfield, Dec 28, 2007
    #10
  11. jeniffer

    user923005 Guest

    On Dec 28, 12:00 am, Richard Heathfield <> wrote:
    > Dann Corbit said:
    >
    > <snip>
    >
    > > Look on the net for cdecl.zip

    >
    > I have done so. I even found it. The zip file was corrupted...
    >
    > > There are other distributions as well (e.g. in BSD code base)

    >
    > ...so I found a version written by Graham Ross, supposedly converted to
    > ANSI C by David Wolverton, which didn't compile. Once I got it to compile
    > (by removing features), it didn't link. Once I got it to link (by removing
    > more features), it didn't run (segfaulted straight away).
    >
    > The cdecl functionality is a perfectly good example of code that *could* be
    > written in solid, clc-conforming ISO C code. And who knows? Perhaps it has
    > been. If so, where may it be found? And if not, well, I'll add it to my
    > to-do list.


    The one that I have builds fine with MINGW, but not with ANSI/ISO C
    because it uses POSIX features.
    user923005, Dec 28, 2007
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Noah
    Replies:
    5
    Views:
    945
  2. Alex Vinokur
    Replies:
    4
    Views:
    571
    Jonathan Turkanis
    Apr 5, 2004
  3. Ovidesvideo
    Replies:
    4
    Views:
    479
    Andrey Tarasevich
    Dec 10, 2004
  4. kelvSYC
    Replies:
    6
    Views:
    7,208
    Richard Herring
    May 17, 2005
  5. cerr

    pointers, pointers, pointers...

    cerr, Apr 7, 2011, in forum: C Programming
    Replies:
    12
    Views:
    652
Loading...

Share This Page