initializing array using pointer

A

arun

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

saurabh

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

slebetman

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

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++;
}
 
C

Christopher Benson-Manica

Johny said:
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.com, 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.
 
K

Kenny McCormack

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.com, 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.

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).
 
R

Richard Bos

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

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

Richard
 
K

Kenny McCormack

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

Richard

To borrow a line from a fellow troll:

You say that like it would be a Bad Thing.
 
S

Skarmander

Richard said:
Neither will you, but if we stop trying your kind will have won and all
will be barbarity.
You already stopped trying. Please, DFTT, no matter what. Every reply is a loss.

S.
 
D

Default User

Richard said:
(e-mail address removed) (Kenny McCormack) wrote:


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

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
 
C

Chuck F.

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

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

Mark McIntyre

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

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

Kenny McCormack

Chuck F. said:
And experience has shown that a non-vanishing fraction of googlers
are capable of learning.

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

Agreed.
 
C

Christopher Benson-Manica

Chuck F. said:
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.

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

Chuck F.

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

Disagreeing. As long as that non-vanishing fraction can learn and
become reasonable netizens, it is worthwhile advising them.
 
K

Keith Thompson

Christopher Benson-Manica said:
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.com, 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.

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

slebetman

Chuck said:
Disagreeing. As long as that non-vanishing fraction can learn and
become reasonable netizens, it is worthwhile advising them.

Yes, worked on ME, you I've only clicked the "reply" thing once on
google - for my first post. Keep up the good work regardless of what
people say. It's certainly effective.
 
K

Kenny McCormack

Disagreeing. As long as that non-vanishing fraction can learn and
become reasonable netizens, it is worthwhile advising them.

So I can interpret "non-vanishing" as "non-zero" (or, in mathematical
terms, some epsilon where epsilon > 0) ?

In any case, my point is that googlers come and googlers go - so even if
you managed to "educate" 1 in 10 in any given day, tomorrow, there'll be
a whole new horde of the unwashed - and they'll be gone by nightfall, never
to return, but simply to be replaced by a new horde.

Plus, there's the whole question of whether anybody *should* change their
behavior simply because they are asked (granted, asked nicely) to do so,
when that behavior change goes against their optical perception of the
world. Granted, there are some people like this and more power *to* them,
but they are rare.
 
J

Jack Klein

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

Richard

If you keep wasting your breath on this jerk, his kind will have won
and all will be trollish.

Arguing with a troll will get you nowhere, but it will amuse the troll
and encourage him to keep at it.

I plonked this rectum a long, long time ago, and would never see his
name except for those who can't resist feeding the troll.

So you have now been warned about your breach of etiquette. If you
don't like the idiot's defense of Google top-posters, do the decent
thing and plonk him.
 
K

Kenny McCormack

Jack Klein said:
So you have now been warned about your breach of etiquette. If you
don't like the idiot's defense of Google top-posters, do the decent
thing and plonk him.

Where do you get me "defending" Google top-posters???

Unless you think that umbrella makers are defending the rain?
Hint: You have no more control over top-posters than you do over the
weather.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top