for(;0;) printf("hello");

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Spidey

    #1

    for(;0;) printf("hello");

    for(;0;)
    printf("hello") ;

    even the condition s wrong i get a hello printed on the screen
    y s this happening

  • Richard Heathfield

    #2
    Re: for(;0;) printf("he llo");

    Spidey said:
    for(;0;)
    printf("hello") ;
    >
    even the condition s wrong i get a hello printed on the screen
    y s this happening
    Y h n p e c.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999

    email: rjh at above domain (but drop the www, obviously)

    Comment

    • Spiros Bousbouras

      #3
      Re: for(;0;) printf("he llo");

      Richard Heathfield wrote:
      Spidey said:
      >
      for(;0;)
      printf("hello") ;

      even the condition s wrong i get a hello printed on the screen
      y s this happening
      >
      Y h n p e c.
      Th s n exl rpl ; i ws i hd tht f it mslf.

      Comment

      • Simon Biber

        #4
        Re: for(;0;) printf("he llo");

        Richard Heathfield wrote:
        Spidey said:
        >
        >for(;0;)
        >printf("hello" );
        >>
        >even the condition s wrong i get a hello printed on the screen
        >y s this happening
        >
        Y h n p e c.
        "You have not posted entire code."?

        #include <stdio.h>

        int main(void)
        {
        for(;0;)
        printf("hello") ;

        return 0;
        }

        I tried it on 4 different compilers and none of them printed hello on
        the screen. One of them warned about unreachable code.

        --
        Simon.

        Comment

        • Aman JIANG

          #5
          Re: for(;0;) printf(&quot;he llo&quot;);

          Spiros Bousbouras wrote:
          Th s n exl rpl ; i ws i hd tht f it mslf.
          I cannot understand this at all.
          What's the meanning please ...

          Comment

          • Spiros Bousbouras

            #6
            Re: for(;0;) printf(&quot;he llo&quot;);

            Aman JIANG wrote:
            Spiros Bousbouras wrote:
            Th s n exl rpl ; i ws i hd tht f it mslf.
            >
            I cannot understand this at all.
            What's the meanning please ...
            You mean you can understand Y h n p e c ?

            Comment

            • Simon Biber

              #7
              Re: for(;0;) printf(&quot;he llo&quot;);

              Aman JIANG wrote:
              Spiros Bousbouras wrote:
              >Th s n exl rpl ; i ws i hd tht f it mslf.
              >
              I cannot understand this at all.
              What's the meanning please ...
              "This is an excellent reply; I wish I had thought of it myself."

              The problem with communicating in such abbreviated forms is that it is
              difficult and slow for to read for some and impossible for others.

              --
              Simon.

              Comment

              • Richard Heathfield

                #8
                Re: for(;0;) printf(&quot;he llo&quot;);

                Simon Biber said:
                Richard Heathfield wrote:
                >Spidey said:
                >>
                >>for(;0;)
                >>printf("hello ");
                >>>
                >>even the condition s wrong i get a hello printed on the screen
                >>y s this happening
                >>
                >Y h n p e c.
                >
                "You have not posted entire code."?
                Not what I had in mind, although you did get the first three words right.

                As you have demonstrated, the more letters that are gratuitously omitted
                from the words of an article, the harder it is to decide what the author
                meant.

                --
                Richard Heathfield
                "Usenet is a strange place" - dmr 29/7/1999

                email: rjh at above domain (but drop the www, obviously)

                Comment

                • Bill Pursell

                  #9
                  Re: for(;0;) printf(&quot;he llo&quot;);


                  Richard Heathfield wrote:
                  Simon Biber said:
                  >
                  Richard Heathfield wrote:
                  Spidey said:
                  >
                  >for(;0;)
                  >printf("hello" );
                  >>
                  >even the condition s wrong i get a hello printed on the screen
                  >y s this happening
                  >
                  Y h n p e c.
                  "You have not posted entire code."?
                  >
                  Not what I had in mind, although you did get the first three words right.
                  "You have not provided enough context" ?

                  --
                  Bill Pursell

                  Comment

                  • Frederick Gotham

                    #10
                    Re: for(;0;) printf(&quot;he llo&quot;);

                    Simon Biber posted:
                    #include <stdio.h>
                    >
                    int main(void)
                    {
                    for(;0;)
                    printf("hello") ;
                    >
                    return 0;
                    }
                    >
                    I tried it on 4 different compilers and none of them printed hello on
                    the screen. One of them warned about unreachable code.

                    Lookup how a "for" loop works and all will become clear.

                    HINT: The conditional to be tested in the above snippet is always false.

                    --

                    Frederick Gotham

                    Comment

                    • Spidey

                      #11
                      Re: for(;0;) printf(&quot;he llo&quot;);

                      am using turbo c3 n it wont put up any warning.
                      and the code produced the hello output on my screen

                      Comment

                      • Spiros Bousbouras

                        #12
                        Re: for(;0;) printf(&quot;he llo&quot;);

                        Spidey wrote:
                        am using turbo c3 n it wont put up any warning.
                        and the code produced the hello output on my screen
                        Are you tidyspidey ?

                        Comment

                        • Frederick Gotham

                          #13
                          Re: for(;0;) printf(&quot;he llo&quot;);

                          Spidey posted:
                          am using turbo c3 n it wont put up any warning.
                          and the code produced the hello output on my screen

                          Speak English.

                          --

                          Frederick Gotham

                          Comment

                          • Michal Nazarewicz

                            #14
                            Re: for(;0;) printf(&quot;he llo&quot;);

                            "Spidey" <amalhashim@gma il.comwrites:
                            for(;0;)
                            printf("hello") ;
                            >
                            even the condition s wrong i get a hello printed on the screen
                            y s this happening
                            Your compiler is broken? You are not using C compiler but some
                            compiler for a /type-name-here/ language which was developed 666 hours
                            ago by a crazy programmer who wants to take over the World? You have
                            put ';' after ')' and haven't noticed it?

                            BTW. SAA#1.

                            --
                            Best regards, _ _
                            .o. | Liege of Serenly Enlightened Majesty of o' \,=./ `o
                            ..o | Computer Science, Michal "mina86" Nazarewicz (o o)
                            ooo +--<mina86*tlen.pl >--<jid:mina86*jab ber.org>--ooO--(_)--Ooo--

                            Comment

                            • Frederick Gotham

                              #15
                              Re: for(;0;) printf(&quot;he llo&quot;);

                              Michal Nazarewicz posted:
                              You have put ';' after ')' and haven't noticed it?

                              I see nothing wrong with the code fragment:

                              for(;0;)
                              printf("hello") ;

                              --

                              Frederick Gotham

                              Comment

                              Working...