initializing array using pointer

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

    initializing array using pointer

    suppose i have a pointer to an array of integers.can i initialize each
    member of the array using pointers?plz explain

  • saurabh

    #2
    Re: initializing array using pointer

    Hi,

    You can assign values to array elements using pointer. Look at the code
    below:

    main ()
    {
    int array[3];
    int *pArry, count;

    pArry = array;

    *pArry = 1; pArry++;
    *pArry =2; pArry++;
    *pArry =3;

    for (count = 0; count <3; count++)
    printf ("array[%d] contains %d\r\n",count, array[count]);

    }

    Is this what you want.

    Regards,
    Saurabh.

    arun wrote:[color=blue]
    > suppose i have a pointer to an array of integers.can i initialize each
    > member of the array using pointers?plz explain[/color]

    Comment

    • slebetman@yahoo.com

      #3
      Re: initializing array using pointer

      arun wrote:[color=blue]
      > suppose i have a pointer to an array of integers.can i initialize each
      > member of the array using pointers?plz explain[/color]

      You mean something like:

      #define ARR_MAX 100

      int arr[ARR_MAX];
      int *myptr;
      int i;

      myptr = arr;
      for(i=0; i<ARR_MAX; i++) {
      *myptr = 0;
      myptr++;
      }

      Comment

      • Johny

        #4
        Re: initializing array using pointer

        Question not clear.

        Comment

        • Christopher Benson-Manica

          #5
          OT, Google boilerplate (was: Re: initializing array using pointer)

          Johny <inform.inn@gma il.com> wrote:
          [color=blue]
          > Question not clear.[/color]

          Neither was your response:

          It is proper Usenet etiquette to include the relevant portions of the text
          you are replying to. To do this using Google groups, please follow the
          instructions below, penned by Keith Thompson:

          If you want to post a followup via groups.google.c om, don't use
          the broken "Reply" link at the bottom of the article. Click on
          "show options" at the top of the article, then click on the
          "Reply" at the bottom of the article headers.

          --
          Christopher Benson-Manica | I *should* know what I'm talking about - if I
          ataru(at)cybers pace.org | don't, I need to know. Flames welcome.

          Comment

          • Kenny McCormack

            #6
            Re: OT, Google boilerplate (was: Re: initializing array using pointer)

            In article <dnmncm$duq$1@c hessie.cirr.com >,
            Christopher Benson-Manica <ataru@nospam.c yberspace.org> wrote:[color=blue]
            >Johny <inform.inn@gma il.com> wrote:
            >[color=green]
            >> Question not clear.[/color]
            >
            >Neither was your response:
            >
            >It is proper Usenet etiquette to include the relevant portions of the text
            >you are replying to. To do this using Google groups, please follow the
            >instructions below, penned by Keith Thompson:
            >
            >If you want to post a followup via groups.google.c om, don't use
            >the broken "Reply" link at the bottom of the article. Click on
            >"show options" at the top of the article, then click on the
            >"Reply" at the bottom of the article headers.[/color]

            You (and others, such as Keith) are wasting your breath. They'll never get
            it. And I'll tell you why.

            Imagine that there's a mouse - and the mouse is the Usenet. You and I can
            see that it is a mouse and we behave accordingly. But now there is a class
            of users (we'll call them "googlers") that are wearing these funny weird
            glasses that make them see not a mouse, but an elephant. Seeing an
            elephant (i.e., the Usenet as a web page), they also behave accordingly.
            And no amount of verbiage from us is going to convince them that it's not
            an elephant - that it is only a mouse.

            To make this more clear, to a googler, it doesn't make any sense to "quote"
            (whatever the heck that is...), in fact, to do so would be absurd, when all
            the rest of the articles in the thread are right there in front of their
            faces (just as clear as the trunk on that mouse, er, elephant). And no
            amount of verbiage from us is going to convince them not to believe what
            they see. The point is you can *never* convince someone that what they see
            isn't reality. The only way you can address the problem is to help them
            fix their eyesight (or help them remove their funny glasses).

            Comment

            • Richard Bos

              #7
              Re: OT, Google boilerplate (was: Re: initializing array using pointer)

              gazelle@yin.int eraccess.com (Kenny McCormack) wrote:
              [color=blue]
              > In article <dnmncm$duq$1@c hessie.cirr.com >,
              > Christopher Benson-Manica <ataru@nospam.c yberspace.org> wrote:[color=green]
              > >Johny <inform.inn@gma il.com> wrote:
              > >[color=darkred]
              > >> Question not clear.[/color]
              > >
              > >Neither was your response:
              > >
              > >It is proper Usenet etiquette to include the relevant portions of the text
              > >you are replying to. To do this using Google groups, please follow the
              > >instructions below, penned by Keith Thompson:
              > >
              > >If you want to post a followup via groups.google.c om, don't use
              > >the broken "Reply" link at the bottom of the article. Click on
              > >"show options" at the top of the article, then click on the
              > >"Reply" at the bottom of the article headers.[/color]
              >
              > You (and others, such as Keith) are wasting your breath. They'll never get it.[/color]

              Neither will you, but if we stop trying your kind will have won and all
              will be barbarity.

              Richard

              Comment

              • Kenny McCormack

                #8
                Re: OT, Google boilerplate (was: Re: initializing array using pointer)

                In article <439ef48c.43559 4684@news.xs4al l.nl>,
                Richard Bos <rlb@hoekstra-uitgeverij.nl> wrote:[color=blue]
                >gazelle@yin.in teraccess.com (Kenny McCormack) wrote:
                >[color=green]
                >> In article <dnmncm$duq$1@c hessie.cirr.com >,
                >> Christopher Benson-Manica <ataru@nospam.c yberspace.org> wrote:[color=darkred]
                >> >Johny <inform.inn@gma il.com> wrote:
                >> >
                >> >> Question not clear.
                >> >
                >> >Neither was your response:
                >> >
                >> >It is proper Usenet etiquette to include the relevant portions of the
                >> >text you are replying to. To do this using Google groups, please
                >> >follow the instructions below, penned by Keith Thompson:
                >> >
                >> >If you want to post a followup via groups.google.c om, don't use
                >> >the broken "Reply" link at the bottom of the article. Click on
                >> >"show options" at the top of the article, then click on the
                >> >"Reply" at the bottom of the article headers.[/color]
                >>
                >> You (and others, such as Keith) are wasting your breath. They'll never
                >> get it.[/color]
                >
                >Neither will you, but if we stop trying your kind will have won and all
                >will be barbarity.
                >
                >Richard[/color]

                To borrow a line from a fellow troll:

                You say that like it would be a Bad Thing.

                Comment

                • Skarmander

                  #9
                  Re: OT, Google boilerplate

                  Richard Bos wrote:[color=blue]
                  > gazelle@yin.int eraccess.com (Kenny McCormack) wrote:
                  >[color=green]
                  >> In article <dnmncm$duq$1@c hessie.cirr.com >,
                  >> Christopher Benson-Manica <ataru@nospam.c yberspace.org> wrote:[color=darkred]
                  >>> Johny <inform.inn@gma il.com> wrote:
                  >>>
                  >>>> Question not clear.
                  >>> Neither was your response:
                  >>>
                  >>> It is proper Usenet etiquette to include the relevant portions of the text
                  >>> you are replying to. To do this using Google groups, please follow the
                  >>> instructions below, penned by Keith Thompson:
                  >>>
                  >>> If you want to post a followup via groups.google.c om, don't use
                  >>> the broken "Reply" link at the bottom of the article. Click on
                  >>> "show options" at the top of the article, then click on the
                  >>> "Reply" at the bottom of the article headers.[/color]
                  >> You (and others, such as Keith) are wasting your breath. They'll never get it.[/color]
                  >
                  > Neither will you, but if we stop trying your kind will have won and all
                  > will be barbarity.
                  >[/color]
                  You already stopped trying. Please, DFTT, no matter what. Every reply is a loss.

                  S.

                  Comment

                  • Default User

                    #10
                    Re: OT, Google boilerplate (was: Re: initializing array using pointer)

                    Richard Bos wrote:
                    [color=blue]
                    > gazelle@yin.int eraccess.com (Kenny McCormack) wrote:[/color]


                    [google reply]
                    [color=blue][color=green]
                    > > You (and others, such as Keith) are wasting your breath. They'll
                    > > never get it.[/color]
                    >
                    > Neither will you, but if we stop trying your kind will have won and
                    > all will be barbarity.[/color]

                    And of course, Kenny is wrong (what a surprise). Many of the people
                    have learned to quote properly via the instructions given to them.
                    Many, if not most, do so because the Google interface is so archane
                    that they couldn't figure out how to do so.

                    With any luck the idjits at Google will switch that around.


                    Brian

                    Comment

                    • Chuck F.

                      #11
                      Re: OT, Google boilerplate

                      Richard Bos wrote:[color=blue]
                      > gazelle@yin.int eraccess.com (Kenny McCormack) wrote:[color=green]
                      >> Christopher Benson-Manica <ataru@nospam.c yberspace.org> wrote:
                      >>[/color][/color]
                      .... snip ...[color=blue][color=green][color=darkred]
                      >>>
                      >>> It is proper Usenet etiquette to include the relevant portions
                      >>> of the text you are replying to. To do this using Google
                      >>> groups, please follow the instructions below, penned by Keith
                      >>> Thompson:
                      >>>
                      >>> "If you want to post a followup via groups.google.c om, don't
                      >>> use the broken "Reply" link at the bottom of the article.
                      >>> Click on "show options" at the top of the article, then click
                      >>> on the "Reply" at the bottom of the article headers."[/color]
                      >>
                      >> You (and others, such as Keith) are wasting your breath.
                      >> They'll never get it.[/color]
                      >
                      > Neither will you, but if we stop trying your kind will have won
                      > and all will be barbarity.[/color]

                      And experience has shown that a non-vanishing fraction of googlers
                      are capable of learning. Similarly, experience has shown that
                      Google itself is incapable of creating a usable interface. They
                      have been plaguing Usenet with this abortion for about a year.

                      --
                      Read about the Sony stealthware that is a security leak, phones
                      home, and is generally illegal in most parts of the world. Also
                      the apparent connivance of the various security software firms.
                      This is my sixth column for Wired.com: It’s a David and Goliath story of the tech blogs defeating a mega-corporation. On Oct. 31, Mark Russinovich broke the story in his blog: Sony BMG Music Entertainment distributed a copy-protection scheme with music CDs that secretly installed a rootkit on computers. This software tool is run without your knowledge or consent—if it’s loaded on your computer with a CD, a hacker can gain and maintain access to your system and you wouldn’t know it. The Sony code modifies Windows so you can’t tell it’s there, a process called “cloaking” in the hacker world. It acts as spyware, surreptitiously sending information about you to Sony. And it can’t be removed; trying to get rid of it ...

                      Comment

                      • Mark McIntyre

                        #12
                        Re: initializing array using pointer

                        On 13 Dec 2005 01:56:25 -0800, in comp.lang.c , "arun"
                        <arkoshy@gmail. com> wrote:
                        [color=blue]
                        >suppose i have a pointer to an array of integers.can i initialize each
                        >member of the array using pointers?plz explain[/color]

                        No. Initialisation is something that happens when you declare the
                        variable.

                        You probably mean assign. In which case sure, just iterate over the
                        array, pointing to each element and assigning it a value.


                        ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
                        http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
                        ----= East and West-Coast Server Farms - Total Privacy via Encryption =----

                        Comment

                        • Kenny McCormack

                          #13
                          Re: OT, Google boilerplate

                          In article <UoydnXiRH48riA LenZ2dnUVZ_s6dn Z2d@maineline.n et>,
                          Chuck F. <cbfalconer@wor ldnet.att.net> wrote:
                          ....[color=blue]
                          >And experience has shown that a non-vanishing fraction of googlers
                          >are capable of learning.[/color]

                          I'm not clear on what you mean by a "non-vanishing fraction". Are you
                          agreeing or disagreeing with my point?

                          In any case, always remember that isolated exceptions do not disprove
                          generalities (except in the sphere of mathematics).
                          [color=blue]
                          >Similarly, experience has shown that Google itself is incapable of
                          >creating a usable interface. They have been plaguing Usenet with this
                          >abortion for about a year.[/color]

                          Agreed.

                          Comment

                          • Christopher Benson-Manica

                            #14
                            Re: OT, Google boilerplate

                            Chuck F. <cbfalconer@yah oo.com> wrote:
                            [color=blue]
                            > And experience has shown that a non-vanishing fraction of googlers
                            > are capable of learning. Similarly, experience has shown that
                            > Google itself is incapable of creating a usable interface. They
                            > have been plaguing Usenet with this abortion for about a year.[/color]

                            Speaking (jestingly) of plaguing Usenet, you've been missing for some
                            time, haven't you? Your contributions have been missed, at least by
                            this poster. Glad to see you back.

                            --
                            Christopher Benson-Manica | I *should* know what I'm talking about - if I
                            ataru(at)cybers pace.org | don't, I need to know. Flames welcome.

                            Comment

                            • Keith Thompson

                              #15
                              Re: OT, Google boilerplate (was: Re: initializing array usingpointer)

                              Christopher Benson-Manica <ataru@nospam.c yberspace.org> writes:[color=blue]
                              > Johny <inform.inn@gma il.com> wrote:
                              >[color=green]
                              >> Question not clear.[/color]
                              >
                              > Neither was your response:
                              >
                              > It is proper Usenet etiquette to include the relevant portions of the text
                              > you are replying to. To do this using Google groups, please follow the
                              > instructions below, penned by Keith Thompson:
                              >
                              > If you want to post a followup via groups.google.c om, don't use
                              > the broken "Reply" link at the bottom of the article. Click on
                              > "show options" at the top of the article, then click on the
                              > "Reply" at the bottom of the article headers.[/color]

                              Or just read <http://cfaj.freeshell. org/google/>.

                              --
                              Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
                              San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
                              We must do something. This is something. Therefore, we must do this.

                              Comment

                              Working...