"Hello World" without semicolon with a difference

Discussion in 'C Programming' started by ankursinha, Feb 19, 2004.

  1. I couldn't find where the standard says the expression is evaluated
    for side effects, which is why I added the 'static' (which clearly
    requires evaluation of the expression). I took the following to mean
    that the expression is not evaluated:

    5 If the size is an expression that is not an integer constant
    expression: if it occurs in a declaration at function prototype
    scope, it is treated as if it were replaced by *; otherwise, each
    time it is evaluated it shall have a value greater than zero.

    Jeremy.
     
    Jeremy Yallop, Feb 20, 2004
    #21
    1. Advertisements

  2. ankursinha

    ankursinha Guest

    I have no idea who Anirudha is???
    I am from India but this is not homework nor has anyone asked me this question
    u may call me stupid but i read those classic interview questions(i agree such
    questions shouldnt be asked at interviews) and i just thought whether such a
    variant wsa possible.That's the reason behind such a question.
    U may call it a fun challenge.
    Thanx a lot.Enjoy Life.
     
    ankursinha, Feb 20, 2004
    #22
    1. Advertisements

  3. ankursinha

    ankursinha Guest

    Shouldnt argv have only one size value in array declaration?

    char *argv[] or char **argv

    Also,could u pls explain the reason of using static.
     
    ankursinha, Feb 20, 2004
    #23
  4. Ok, if it's just a fun challenge, that's perfectly fine with me. In
    the future, I suggest making that more explicit, just to avoid
    possible misunderstandings. We do get a lot of people coming here
    asking us to do their homework for them; if you ask a question that
    looks like it could be homework, it's a good idea to provide some
    background.

    I'm glad to learn that my suspiciouns were unfounded. I'd gladly jump
    into the discussion (I like silly puzzles), but I don't have any ideas
    or sufficient time to come up with any.

    One piece of friendly advice: the abbreviation "u" for "you" is
    generally frowned upon here. We discussed this at far too much length
    not long ago, so I won't go into the reasoning; you can search the
    archives, take my word for it, or ignore me if you wish.
     
    Keith Thompson, Feb 21, 2004
    #24
  5. And less glad to learn that they were misspelled. :cool:}
     
    Keith Thompson, Feb 21, 2004
    #25
  6. When did `u r' become correct English?
     
    August Derleth, Feb 21, 2004
    #26
  7. ankursinha

    Sidney Cadot Guest

    Didn't u get the memo?

    Sidney
     
    Sidney Cadot, Feb 21, 2004
    #27
  8. I've just noticed that this doesn't apply because the VLA declaration
    is not at function prototype scope.

    Jeremy.
     
    Jeremy Yallop, Feb 21, 2004
    #28
  9. ankursinha

    Kevin Handy Guest

    He's not ur, so he gets to use them. Only ur can't use them,
    whoever he is.
     
    Kevin Handy, Feb 21, 2004
    #29
  10. How do you know ur is not a she?
     
    Peter Pichler, Feb 22, 2004
    #30
  11. ankursinha

    CBFalconer Guest

    Because Ur is a city in antiquity.
     
    CBFalconer, Feb 22, 2004
    #31
  12. ankursinha

    Joe Wright Guest

    From about 3000 BC. Birthplace of Abraham. In southeastern Iraq.
    Abandoned around 500 BC.
     
    Joe Wright, Feb 22, 2004
    #32
  13. ankursinha

    Old Wolf Guest

    Is it possible to write a C program that prints "Hello World" on screen without
    Solution 1:

    #error "Hello World"

    (it isn't specified at what stage the text has to be "printed"
    on the "screen")

    Solution 2:

    No.

    (there might not be a screen)

    Solution 3:

    #include <stdio.h>
    int main(void)
    {
    puts("Hello World");;
    }

    (only double semi-colons were used)
     
    Old Wolf, Feb 22, 2004
    #33
  14. Apparently there was no connection between the two articles, and it
    was foolish of me to assume that there was. I saw two seemingly
    similar posts, both from people with seemingly Indian names, and
    assumed the likelihood of a connection. In fact, India is an
    extremely large country, and my assumption was poorly thought out --
    not unlike saying, "You must have met John Smith; he lives in
    America." I apologize.
     
    Keith Thompson, Feb 25, 2004
    #34
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.