C ONE LINER

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • c.lang.myself@gmail.com

    C ONE LINER

    Can you determine output of following one liner by visual inspection..
    It had won an award in obfuscated C contest.....


    main() { printf(&unix["\021%six\012\0 "],(unix)["have"]+"fun"-0×60);}


    You can also list your favourite one liner...
  • christian.bau

    #2
    Re: C ONE LINER

    On Nov 18, 11:29 am, "c.lang.mys...@ gmail.com"
    <c.lang.mys...@ gmail.comwrote:
    Can you determine output of following one liner by visual inspection..
    It had won an award in obfuscated C contest.....
    >
    main() { printf(&unix["\021%six\012\0 "],(unix)["have"]+"fun"-0×60);}
    >
    You can also list your favourite one liner...
    So what is your C related question? Your posts are getting more and
    more nauseous.

    Comment

    • gw7rib@aol.com

      #3
      Re: C ONE LINER

      On 18 Nov, 11:29, "c.lang.mys...@ gmail.com" <c.lang.mys...@ gmail.com>
      wrote:
      Can you determine output of following one liner by visual inspection..
      It had won an award in obfuscated C contest.....
      >
      main() { printf(&unix["\021%six\012\0 "],(unix)["have"]+"fun"-0×60);}
      Is "unix" supposed to be defined and, if so, as what?

      Comment

      • Martien Verbruggen

        #4
        Re: C ONE LINER

        On Tue, 18 Nov 2008 15:12:42 -0800 (PST),
        gw7rib@aol.com <gw7rib@aol.com wrote:
        On 18 Nov, 11:29, "c.lang.mys...@ gmail.com" <c.lang.mys...@ gmail.com>
        wrote:
        >Can you determine output of following one liner by visual inspection..
        >It had won an award in obfuscated C contest.....
        >>
        >main() { printf(&unix["\021%six\012\0 "],(unix)["have"]+"fun"-0×60);}
        >
        Is "unix" supposed to be defined and, if so, as what?
        It's the 1987 IOCCC entry by David Korn. Look it up with Google.

        Martien
        --
        |
        Martien Verbruggen | Quick! Hire a teenager while they still know
        | everything.
        |

        Comment

        • CBFalconer

          #5
          Re: C ONE LINER

          gw7rib@aol.com wrote:
          "c.lang.mys...@ gmail.com" <c.lang.mys...@ gmail.comwrote:
          >
          >Can you determine output of following one liner by visual
          >inspection. It had won an award in obfuscated C contest.
          >>
          >main() {printf(&unix["\021%six\012\0 "],(unix)["have"]+"fun"-0×60);}
          >
          Is "unix" supposed to be defined and, if so, as what?
          He says it is a one liner, so there is no way for it to be defined.

          --
          [mail]: Chuck F (cbfalconer at maineline dot net)
          [page]: <http://cbfalconer.home .att.net>
          Try the download section.

          Comment

          • James Kuyper

            #6
            Re: C ONE LINER

            CBFalconer wrote:
            gw7rib@aol.com wrote:
            >"c.lang.mys... @gmail.com" <c.lang.mys...@ gmail.comwrote:
            >>
            >>Can you determine output of following one liner by visual
            >>inspection. It had won an award in obfuscated C contest.
            >>>
            >>main() {printf(&unix["\021%six\012\0 "],(unix)["have"]+"fun"-0×60);}
            >Is "unix" supposed to be defined and, if so, as what?
            >
            He says it is a one liner, so there is no way for it to be defined.
            Giving the compiler the command line option "-Dunix=1" would make that
            code work as expected on most of the C89 compilers I've ever used.

            There were compilers that pre-defined 'unix' automatically. Such
            compilers do not conform to any version of the C standard, but that
            doesn't make them non-existent. It does make code which relies on their
            non-conforming features off-topic.

            Comment

            • CBFalconer

              #7
              Re: C ONE LINER

              James Kuyper wrote:
              CBFalconer wrote:
              >gw7rib@aol.com wrote:
              >>"c.lang.mys.. .@gmail.com" <c.lang.mys...@ gmail.comwrote:
              >>>
              >>>Can you determine output of following one liner by visual
              >>>inspection . It had won an award in obfuscated C contest.
              >>>>
              >>>main() {printf(&unix["\021%six\012\0 "],(unix)["have"]+"fun"-0×60);}
              >>Is "unix" supposed to be defined and, if so, as what?
              >>
              >He says it is a one liner, so there is no way for it to be defined.
              >
              Giving the compiler the command line option "-Dunix=1" would make that
              code work as expected on most of the C89 compilers I've ever used.
              Didn't think of that :-)

              --
              [mail]: Chuck F (cbfalconer at maineline dot net)
              [page]: <http://cbfalconer.home .att.net>
              Try the download section.

              Comment

              • Keith Thompson

                #8
                Re: C ONE LINER

                gw7rib@aol.com writes:
                On 18 Nov, 11:29, "c.lang.mys...@ gmail.com" <c.lang.mys...@ gmail.com>
                wrote:
                >Can you determine output of following one liner by visual inspection..
                >It had won an award in obfuscated C contest.....
                >>
                >main() { printf(&unix["\021%six\012\0 "],(unix)["have"]+"fun"-0×60);}
                >
                Is "unix" supposed to be defined and, if so, as what?
                Many years ago, Unix C compilers typically predefined the macro
                "unix", so programmers could write:

                #ifdef unix
                /* Unix-specific code */
                #endif

                Modern C compilers aren't allowed to do that, since "unix" is in the
                programmer's namespace, but the early compilers didn't make any such
                guarantees.

                The above code, (with "0?60" replaced by "0x60") is from the 1987
                International Obfuscated C Code Contest (IOCCC); it was submitted by
                David Korn, author of the Korn shell. If you want spoilers, go to
                <http://www.ioccc.org/>.

                --
                Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
                Nokia
                "We must do something. This is something. Therefore, we must do this."
                -- Antony Jay and Jonathan Lynn, "Yes Minister"

                Comment

                • James Kuyper

                  #9
                  Re: C ONE LINER

                  Keith Thompson wrote:
                  gw7rib@aol.com writes:
                  >On 18 Nov, 11:29, "c.lang.mys...@ gmail.com" <c.lang.mys...@ gmail.com>
                  ....
                  >>main() { printf(&unix["\021%six\012\0 "],(unix)["have"]+"fun"-0×60);}
                  ....
                  The above code, (with "0?60" replaced by "0x60") is from the 1987
                  For all messages I've seen on this thread, that text displays as 0x60,
                  not 0?60, both from my Thunderbird newsreader and when using Firefox to
                  view the messages on Google Groups.

                  Comment

                  • Bill Leary

                    #10
                    Re: C ONE LINER

                    "James Kuyper" <jameskuyper@ve rizon.netwrote in message
                    news:BhSUk.2337 $mi4.1430@nwrdd c02.gnilink.net ...
                    Keith Thompson wrote:
                    >gw7rib@aol.com writes:
                    >>On 18 Nov, 11:29, "c.lang.mys...@ gmail.com" <c.lang.mys...@ gmail.com>
                    ...
                    >>>main() { printf(&unix["\021%six\012\0 "],(unix)["have"]+"fun"-0×60);}
                    ...
                    >The above code, (with "0?60" replaced by "0x60") is from the 1987
                    >
                    For all messages I've seen on this thread, that text displays as 0x60, not
                    0?60, both from my Thunderbird newsreader and when using Firefox to view
                    the messages on Google Groups.
                    Mine is displaying it as the "times" symbol rather than the letter "x".
                    That is, it's not the same character as the "x" in "unix" at the start of
                    the line. If I save it and do a binary dump on it, it comes up as code 0xD7
                    rather than the 0x78 of a lower case "x". I assume Keith's news reader
                    substitutes "?" when the character code is outside the standard ASCII set.

                    - Bill

                    Comment

                    • James Kuyper

                      #11
                      Re: C ONE LINER

                      Bill Leary wrote:
                      "James Kuyper" <jameskuyper@ve rizon.netwrote in message
                      news:BhSUk.2337 $mi4.1430@nwrdd c02.gnilink.net ...
                      >Keith Thompson wrote:
                      >>gw7rib@aol.com writes:
                      >>>On 18 Nov, 11:29, "c.lang.mys...@ gmail.com" <c.lang.mys...@ gmail.com>
                      >...
                      >>>>main() { printf(&unix["\021%six\012\0 "],(unix)["have"]+"fun"-0×60);}
                      >...
                      >>The above code, (with "0?60" replaced by "0x60") is from the 1987
                      >>
                      >For all messages I've seen on this thread, that text displays as 0x60,
                      >not 0?60, both from my Thunderbird newsreader and when using Firefox
                      >to view the messages on Google Groups.
                      >
                      Mine is displaying it as the "times" symbol rather than the letter "x".
                      You're right, I missed that distinction - I can see the difference, now
                      that I know what to look for. I've just checked, and it displays as the
                      "times" symbol in all messages in this thread.

                      Comment

                      • Richard Tobin

                        #12
                        Re: C ONE LINER

                        In article <BhSUk.2337$mi4 .1430@nwrddc02. gnilink.net>,
                        James Kuyper <jameskuyper@ve rizon.netwrote:
                        >For all messages I've seen on this thread, that text displays as 0x60,
                        >not 0?60, both from my Thunderbird newsreader and when using Firefox to
                        >view the messages on Google Groups.
                        It's a Latin-1 multiplication symbol, which looks very like a letter-x.

                        -- Richard
                        --
                        Please remember to mention me / in tapes you leave behind.

                        Comment

                        • Martin Ambuhl

                          #13
                          Re: C ONE LINER

                          James Kuyper wrote:
                          Keith Thompson wrote:
                          >gw7rib@aol.com writes:
                          >>On 18 Nov, 11:29, "c.lang.mys...@ gmail.com" <c.lang.mys...@ gmail.com>
                          ....
                          >>>main() { printf(&unix["\021%six\012\0 "],(unix)["have"]+"fun"-0×60);}
                          ....
                          >The above code, (with "0?60" replaced by "0x60") is from the 1987
                          >
                          For all messages I've seen on this thread, that text displays as 0x60,
                          not 0?60, both from my Thunderbird newsreader and when using Firefox to
                          view the messages on Google Groups.
                          No, it doesn't. Firefox properly renders the non-ascii character in
                          "0×60" as '×', not 'x'.

                          Comment

                          • Keith Thompson

                            #14
                            Re: C ONE LINER

                            Martin Ambuhl <mambuhl@earthl ink.netwrites:
                            James Kuyper wrote:
                            >Keith Thompson wrote:
                            >>gw7rib@aol.com writes:
                            >>>On 18 Nov, 11:29, "c.lang.mys...@ gmail.com" <c.lang.mys...@ gmail.com>
                            >....
                            >>>>main() { printf(&unix["\021%six\012\0 "],(unix)["have"]+"fun"-0×60);}
                            >....
                            >>The above code, (with "0?60" replaced by "0x60") is from the 1987
                            >For all messages I've seen on this thread, that text displays as
                            >0x60, not 0?60, both from my Thunderbird newsreader and when using
                            >Firefox to view the messages on Google Groups.
                            >
                            No, it doesn't. Firefox properly renders the non-ascii character in
                            "0×60" as '×', not 'x'.
                            It probably depends on how Firefox and the underlying OS are
                            configured, and what assumptions Firefox makes about the web page it's
                            trying to render.

                            --
                            Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
                            Nokia
                            "We must do something. This is something. Therefore, we must do this."
                            -- Antony Jay and Jonathan Lynn, "Yes Minister"

                            Comment

                            • Kevin D. Quitt

                              #15
                              Re: C ONE LINER

                              >main() { printf(&unix["\021%six\012\0 "],(unix)["have"]+"fun"-0×60);}

                              Nowadays, it'd have to be a two-liner: the Standard (5.1.1.2 P 1, section
                              2) "A source file that is not empty shall end in a new-line character..."


                              --
                              #include <standard.discl aimer>
                              _
                              Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up

                              Comment

                              Working...