memory layout and declaration

This is a discussion on memory layout and declaration within the C Programming forums, part of the General Programming Boards category; I came across the decleration. Code: int *x[](); According to me it is: x is an array of pointers pointing ...

  1. #1
    Registered User cbastard's Avatar
    Join Date
    Jul 2005
    Location
    India
    Posts
    167

    declaration

    I came across the decleration.
    Code:
    int *x[]();
    According to me it is: x is an array of pointers pointing to a function which returns int.
    But the answer was different so i just want to check.So just tell your opinion about it.
    wat is a memory layout of c program.is it code segment,data segment ,stack n heap??help urgent
    Last edited by cbastard; 09-12-2005 at 12:26 PM.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,264
    That code is not valid C.

  3. #3
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    712
    bithub is right, compiler will scream error if you try to compile it.
    Did you mean
    Code:
    int (*x[])();
    maybe?

    - Micko
    Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
    It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem

  4. #4
    Nonconformist Narf's Avatar
    Join Date
    Aug 2005
    Posts
    174
    But the answer was different so i just want to check.So just tell your opinion about it.
    wat is a memory layout of c program.is it code segment,data segment ,stack n heap??
    I'm dying to know how an invalid declaration prompted a question about memory layout.
    Just because I don't care doesn't mean I don't understand.

  5. #5
    Registered User cbastard's Avatar
    Join Date
    Jul 2005
    Location
    India
    Posts
    167
    Code:
    int (*x[])();
    that would be a piece of cake .
    Code:
    int  *x[]();
    I did'nt check it in c compiler actually that was not in the options.I cant scan the paper to show this question but it came in a written exam of a leading software soln company.
    I'm dying to know how an invalid declaration prompted a question about memory layout
    sorry that was a different question.anyways thanks for your help

  6. #6
    ---
    Join Date
    May 2004
    Posts
    1,379
    wat is a memory layout of c program.is it code segment,data segment ,stack n heap??help urgent
    He wanted to know what memory layout meant.

  7. #7
    Registered User cbastard's Avatar
    Join Date
    Jul 2005
    Location
    India
    Posts
    167
    Quote Originally Posted by sand_man
    He wanted to know what memory layout meant.
    Thats what my original question was.

    Memory layout means how the program is allocated on main memory or How the c program is stored on memory.
    Ans. The c program in memory contains 4 segments which i mentioned earlier

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21