q3b

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

    q3b

    Mark,

    I don't know how to do this with spaces or for. So I will post another way
    of doing it and I don't know how to include spaces. But the program works.

    Bill

    #include <stdio.h>

    int main (void) {
    char a[]={'0','1','2',' 3','4','5','6'} ;
    printf("%s\n",a );
    }


  • Ben Bacarisse

    #2
    Re: q3b

    "Bill Cunningham" <nospam@nspam.c omwrites:
    Mark,
    >
    I don't know how to do this with spaces or for. So I will post another way
    of doing it and I don't know how to include spaces. But the program
    works.
    You were unlucky. I have more luck, it seems. On my system I get:

    0123456�-��H.��P t���lï¿½ï ¿½ÐƒH.��Ptï ¿½ï¿½

    Do you know why?
    #include <stdio.h>
    >
    int main (void) {
    char a[]={'0','1','2',' 3','4','5','6'} ;
    I am surprised that:

    char a[]={'0',' ','1',' ','2',' ','3',' ','4',' ','5',' ','6'};

    did not occur to you. Knowing why you did not think of it is probably
    more helpful than getting the program right. For example, did you
    look for, and not find, a special escape sequence for a space
    character (like there is for newline: '\n'). If so what did you do
    when you did not find it? Maybe you simply did not know how to write
    a space and you don't know any way to find such things out. I have a
    feeling that examining these questions will be more helpful to you
    than someone telling you how to write a space.
    printf("%s\n",a );
    }
    --
    Ben.

    Comment

    • Bill Cunningham

      #3
      Re: q3b


      "Ben Bacarisse" <ben.usenet@bsb .me.ukwrote in message
      news:87fxpv5asv .fsf@bsb.me.uk. ..
      I am surprised that:
      >
      char a[]={'0',' ','1',' ','2',' ','3',' ','4',' ','5',' ','6'};
      >
      Actually it did enter my mind but I figured some strange code would occur.
      did not occur to you. Knowing why you did not think of it is probably
      more helpful than getting the program right. For example, did you
      look for, and not find, a special escape sequence for a space
      character (like there is for newline: '\n'). If so what did you do
      when you did not find it? Maybe you simply did not know how to write
      a space and you don't know any way to find such things out. I have a
      feeling that examining these questions will be more helpful to you
      than someone telling you how to write a space.
      >
      > printf("%s\n",a );
      > }
      >
      --
      Ben.

      Comment

      • Wolfgang Draxinger

        #4
        Re: q3b

        Ben Bacarisse wrote:
        "Bill Cunningham" <nospam@nspam.c omwrites:
        > Mark,
        >>
        >I don't know how to do this with spaces or for. So I will post
        >another way of doing it and I don't know how to include
        >spaces. But the program works.
        You were unlucky. I have more luck, it seems. On my system I
        get:

        0123456�-��H.��P t���lï¿½ï ¿½ÐƒH.��Ptï ¿½ï¿½

        Do you know why?
        Think "Zero terminated string".

        char a[]={'0','1','2',' 3','4','5','6', '\0'};

        or

        char a[]={'0','1','2',' 3','4','5','6', 0}; /* mind the missing
        single quotes here */

        Wolfgang Draxinger
        --
        E-Mail address works, Jabber: hexarith@jabber .org, ICQ: 134682867

        Comment

        • Ben Bacarisse

          #5
          Re: q3b

          Wolfgang Draxinger <wdraxinger@dar kstargames.dewr ites:
          Ben Bacarisse wrote:
          >
          >"Bill Cunningham" <nospam@nspam.c omwrites:
          >>
          >> Mark,
          >>>
          >>I don't know how to do this with spaces or for. So I will post
          >>another way of doing it and I don't know how to include
          >>spaces. But the program works.
          >>
          >You were unlucky. I have more luck, it seems. On my system I
          >get:
          >>
          >0123456�-��H.��P t���lï¿½ï ¿½ÐƒH.��Ptï ¿½ï¿½
          >>
          >Do you know why?
          >
          Think "Zero terminated string".
          Well, I knew that...
          char a[]={'0','1','2',' 3','4','5','6', '\0'};
          Oh, well, so much for hoping Bill will work it out!

          --
          Ben.

          Comment

          • Keith Thompson

            #6
            Re: q3b

            "Bill Cunningham" <nospam@nspam.c omwrites:
            I don't know how to do this with spaces or for. So I will post another way
            of doing it and I don't know how to include spaces. But the program works.
            >
            Bill
            >
            #include <stdio.h>
            >
            int main (void) {
            char a[]={'0','1','2',' 3','4','5','6'} ;
            printf("%s\n",a );
            }
            No, it doesn't "work". It doesn't satisfy the stated requirements.

            Here's another program that doesn't satisfy the stated requirements:

            int main(void) { return 0; }

            It "works" too.

            --
            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

            • Barry Schwarz

              #7
              Re: q3b

              On Sun, 27 Jul 2008 17:45:23 GMT, "Bill Cunningham" <nospam@nspam.c om>
              wrote:
              Mark,
              >
              >I don't know how to do this with spaces or for. So I will post another way
              >of doing it and I don't know how to include spaces. But the program works.
              >
              >Bill
              >
              >#include <stdio.h>
              >
              >int main (void) {
              char a[]={'0','1','2',' 3','4','5','6'} ;
              printf("%s\n",a );
              }
              >
              The only thing this program does is invoke undefined behavior. Since
              you started a new thread, haven't told us what the program is supposed
              to do, but do claim it works, I will give you the benefit of the doubt
              and wonder why you are writing programs specifically to invoke
              undefined behavior.


              Remove del for email

              Comment

              • Richard

                #8
                Re: q3b

                Barry Schwarz <schwarzb@dqel. comwrites:
                On Sun, 27 Jul 2008 17:45:23 GMT, "Bill Cunningham" <nospam@nspam.c om>
                wrote:
                >
                > Mark,
                >>
                >>I don't know how to do this with spaces or for. So I will post another way
                >>of doing it and I don't know how to include spaces. But the program works.
                >>
                >>Bill
                >>
                >>#include <stdio.h>
                >>
                >>int main (void) {
                > char a[]={'0','1','2',' 3','4','5','6'} ;
                > printf("%s\n",a );
                > }
                >>
                >
                The only thing this program does is invoke undefined behavior. Since
                you started a new thread, haven't told us what the program is supposed
                to do, but do claim it works, I will give you the benefit of the doubt
                and wonder why you are writing programs specifically to invoke
                undefined behavior.
                If you are going to confuse an obviously already confused person like
                Bill with such a damning of his work, do you not think it might be a nice
                idea to describe WHY you think his program produces undefined behaviour?
                >
                >
                Remove del for email
                (It might be nice if your put this below a .sig delimiter)

                Comment

                • Barry Schwarz

                  #9
                  Re: q3b

                  On Mon, 28 Jul 2008 05:47:33 +0200, Richard<rgrdev@ gmail.comwrote:
                  >Barry Schwarz <schwarzb@dqel. comwrites:
                  snip
                  >>
                  >Remove del for email
                  >
                  >(It might be nice if your put this below a .sig delimiter)
                  I have tried to add a line -- \n before the demunging instructions.
                  Does it serve as the proper delimiter?

                  --
                  Remove del for email

                  Comment

                  • Richard Heathfield

                    #10
                    Re: q3b

                    Barry Schwarz said:
                    On Mon, 28 Jul 2008 05:47:33 +0200, Richard<rgrdev@ gmail.comwrote:
                    >
                    >>Barry Schwarz <schwarzb@dqel. comwrites:
                    snip
                    >
                    >>>
                    >>Remove del for email
                    >>
                    >>(It might be nice if your put this below a .sig delimiter)
                    >
                    I have tried to add a line -- \n before the demunging instructions.
                    Does it serve as the proper delimiter?
                    Yes. Good chap.

                    --
                    Richard Heathfield <http://www.cpax.org.uk >
                    Email: -http://www. +rjh@
                    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
                    "Usenet is a strange place" - dmr 29 July 1999

                    Comment

                    • Wolfgang Draxinger

                      #11
                      Re: q3b

                      Ben Bacarisse wrote:
                      Oh, well, so much for hoping Bill will work it out!
                      Well, some people just need direct awnsers to learn things. I
                      hated it, then in math classes (university) we just got a bunch
                      of exercises "to work them out", and everytime you asked some
                      question out of curiousity all you got as an awnser were hints
                      in which direction, and which book the solution might be.

                      Why not just tell, how things are? This gives the person who asks
                      the possibility to think a few seconds about it and maybe ask
                      the next question, based on new insight due to the first awnser.

                      Wolfgang Draxinger
                      --
                      E-Mail address works, Jabber: hexarith@jabber .org, ICQ: 134682867

                      Comment

                      • vippstar@gmail.com

                        #12
                        Re: q3b

                        On Jul 28, 4:16 am, Wolfgang Draxinger <wdraxin...@dar kstargames.de>
                        wrote:
                        Ben Bacarisse wrote:
                        Oh, well, so much for hoping Bill will work it out!
                        Bill _can_ work it out, but he doesn't show it because he's a troll.
                        Well, some people just need direct awnsers to learn things. I
                        I thought this was a typo, but since you repeated it, it's "answer".
                        hated it, then in math classes (university) we just got a bunch
                        of exercises "to work them out", and everytime you asked some
                        question out of curiousity all you got as an awnser were hints
                        in which direction, and which book the solution might be.
                        >
                        Why not just tell, how things are? This gives the person who asks
                        the possibility to think a few seconds about it and maybe ask
                        the next question, based on new insight due to the first awnser.
                        "Give a man a fish; you have fed him for today. Teach a man to fish;
                        and you have fed him for a lifetime".

                        Which pretty much means that if one gives you the answer directly,
                        you'll seek answers from him. If one teaches you to find the answers,
                        you won't need anyone else but yourself.

                        Comment

                        • Wolfgang Draxinger

                          #13
                          Re: q3b

                          vippstar@gmail. com wrote:
                          I thought this was a typo, but since you repeated it, it's
                          "answer".
                          Not again... This is the word I keep to misspell constantly.

                          answer, answer, answer, answer, ans... WTH:
                          for(int i=0; i<100; ++i) printf("answer, ");
                          "Give a man a fish; you have fed him for today. Teach a man to
                          fish; and you have fed him for a lifetime".
                          >
                          Which pretty much means that if one gives you the answer
                          directly, you'll seek answers from him. If one teaches you to
                          find the answers, you won't need anyone else but yourself.
                          Give a man a fish and he might get the idea, where to get food
                          from.

                          Wolfgang Draxinger
                          --
                          E-Mail address works, Jabber: hexarith@jabber .org, ICQ: 134682867

                          Comment

                          • vippstar@gmail.com

                            #14
                            Re: q3b

                            On Jul 28, 10:35 pm, Wolfgang Draxinger <wdraxin...@dar kstargames.de>
                            wrote:
                            vipps...@gmail. com wrote:
                            "Give a man a fish; you have fed him for today. Teach a man to
                            fish; and you have fed him for a lifetime".
                            >
                            Which pretty much means that if one gives you the answer
                            directly, you'll seek answers from him. If one teaches you to
                            find the answers, you won't need anyone else but yourself.
                            >
                            Give a man a fish and he might get the idea, where to get food
                            from.
                            Yeah, the idea he'll get is to get the food from _you_, not from
                            fishing. I hope you do see my point now.

                            Comment

                            • S James S Stapleton

                              #15
                              Re: q3b

                              Yeah, the idea he'll get is to get the food from _you_, not from
                              fishing. I hope you do see my point now.
                              Not necessarily. A man has only been eating 'chicken of the sea' (that's
                              canned, processed tuna).

                              If CotS suddenly stops producing, And you hand him a fishing pole and a net,
                              he's going to look at you funny.
                              That's what some people seem to thing is teaching a man to fish. Even if you
                              hand the guy a few tuna, and say 'you can use the pole and net to get them
                              from over in the ocean', he'll still look at you funny because he doesn't
                              have the context, he doesn't have the context to know those little fish can
                              be ground up to make his (revolting) culinary delight.

                              Yes, don't give the man a fish, teach him to fish. However, try to find what
                              context he has so you know what to teach him, rather than just showing some
                              little bit of stuff, which is likely as not, going to confuse him.

                              And when you hand him the pole when he's wondering how to get food, don't
                              say "betcha didn't think about using one of these, did ya?" Of course not.
                              He didn't have the context. Think about (or ask) /why/, otherwise you aren't
                              helping the person learn any more than you would just handing him a fish,
                              but instead of helping him in the short term, you are hurting him in the
                              short and long term.


                              Comment

                              Working...