linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: HIToC <hitoc_mail@yahoo.it>
To: ework0 <ework0@gmail.com>
Cc: Linux C programming <linux-c-programming@vger.kernel.org>
Subject: Re: pointers
Date: Mon, 31 Oct 2005 14:07:03 +0100	[thread overview]
Message-ID: <200510301947.09432.hitoc_mail@yahoo.it> (raw)
In-Reply-To: <43648017.7040700@gmail.com>

On Sunday 30 October 2005 09:11, ework0 wrote:
> I would like to know what are the advantages of use pointers to
> insert/modify values in an array of characters for example.

With a pointer you can have access to a single element of an
array in a very easy and fast way. Probably your example was
not the best for this purpose; considere this one:

char str[16] = "0123456789ABCDEF";
char* p = str;

Now p points to the first element of the array str. If you want
to obtain or to modify the element pointed by p, you can do
this by simply operating on p. Remember that the operations
like p++, will not modify the element pointed by p, but only
p will point the next element in the array.


> what is the advantages of use this manipulation of array with these
> pointers ?

When you have to scan big sequences of objects, is a very common
way to use pointers in order to have the access to a single element
or when you pass an object to a function passing the address and not
to copy the entire object.

A wrong use of pointers can cause errors difficult to find.
-- 
With regards,


					HIToC
					hitoc_mail@yahoo.it

      reply	other threads:[~2005-10-31 13:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-30  8:11 pointers ework0
2005-10-31 13:07 ` HIToC [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200510301947.09432.hitoc_mail@yahoo.it \
    --to=hitoc_mail@yahoo.it \
    --cc=ework0@gmail.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).