Thread: Returning arrays and expressions

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    140

    Returning arrays and expressions

    Hi guys

    I have to non-related questions. I am learning C from K&R.

    1) Do K&R ever say that functions in C cannot return arrays? I am not doubting this claim, but I just do not recall having read this in their book.

    2) Is there a precise definition of an expression?

    Best,
    Niles.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Niels_M
    2) Is there a precise definition of an expression?
    Yes:
    Quote Originally Posted by C99 Section 6.5 Paragraph 1
    An expression is a sequence of operators and operands that specifies computation of a value, or that designates an object or a function, or that generates side effects, or that performs a combination thereof.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Aug 2009
    Posts
    140
    Wow, 5 minutes.. that was fast. Thanks.

    So a function call is an expression because it "generates side effects"?
    Last edited by Niels_M; 08-09-2010 at 01:44 PM.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Niels_M
    So a function call is an expression because it "generates side effects"?
    Yes, and of course it also involves operands with the function call operator.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with pointers and arrays
    By special1zed in forum C Programming
    Replies: 3
    Last Post: 03-15-2009, 09:44 AM