By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,385 Members | 1,763 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,385 IT Pros & Developers. It's quick & easy.

initializing array using pointer

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

Dec 13 '05 #1
Share this Question
Share on Google+
31 Replies


P: n/a
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:
suppose i have a pointer to an array of integers.can i initialize each
member of the array using pointers?plz explain


Dec 13 '05 #2

P: n/a
arun wrote:
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++;
}

Dec 13 '05 #3

P: n/a
Question not clear.

Dec 13 '05 #4

P: n/a
Johny <in********@gmail.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.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.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Dec 13 '05 #5

P: n/a
In article <dn**********@chessie.cirr.com>,
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote:
Johny <in********@gmail.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.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).

Dec 13 '05 #6

P: n/a
ga*****@yin.interaccess.com (Kenny McCormack) wrote:
In article <dn**********@chessie.cirr.com>,
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote:
Johny <in********@gmail.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.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.


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

Richard
Dec 13 '05 #7

P: n/a
In article <43****************@news.xs4all.nl>,
Richard Bos <rl*@hoekstra-uitgeverij.nl> wrote:
ga*****@yin.interaccess.com (Kenny McCormack) wrote:
In article <dn**********@chessie.cirr.com>,
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote:
>Johny <in********@gmail.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.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.


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.

Dec 13 '05 #8

P: n/a
Richard Bos wrote:
ga*****@yin.interaccess.com (Kenny McCormack) wrote:
In article <dn**********@chessie.cirr.com>,
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote:
Johny <in********@gmail.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.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.


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.
Dec 13 '05 #9

P: n/a
Richard Bos wrote:
ga*****@yin.interaccess.com (Kenny McCormack) wrote:

[google reply]
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.


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

Dec 13 '05 #10

P: n/a
Richard Bos wrote:
ga*****@yin.interaccess.com (Kenny McCormack) wrote:
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote:
.... snip ...

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.


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.

--
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.
http://www.schneier.com/blog/archive...drm_rootk.html
Dec 13 '05 #11

P: n/a
On 13 Dec 2005 01:56:25 -0800, in comp.lang.c , "arun"
<ar*****@gmail.com> wrote:
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.
----== 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 =----
Dec 13 '05 #12

P: n/a
In article <Uo******************************@maineline.net> ,
Chuck F. <cb********@worldnet.att.net> wrote:
....
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.
Dec 13 '05 #13

P: n/a
Chuck F. <cb********@yahoo.com> wrote:
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.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Dec 13 '05 #14

P: n/a
Christopher Benson-Manica <at***@nospam.cyberspace.org> writes:
Johny <in********@gmail.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.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/>.

--
Keith Thompson (The_Other_Keith) ks***@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.
Dec 13 '05 #15

P: n/a
Kenny McCormack wrote:
Chuck F. <cb********@worldnet.att.net> wrote:
....
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?


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

--
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.
http://www.schneier.com/blog/archive...drm_rootk.html
Dec 13 '05 #16

P: n/a
Chuck F. wrote:
Kenny McCormack wrote:
Chuck F. <cb********@worldnet.att.net> wrote:
....
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?


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.

Dec 13 '05 #17

P: n/a
In article <hL********************@maineline.net>,
Chuck F. <cb********@worldnet.att.net> wrote:
Kenny McCormack wrote:
Chuck F. <cb********@worldnet.att.net> wrote:
....
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?


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.

Dec 14 '05 #18

P: n/a
On Tue, 13 Dec 2005 16:19:53 GMT, rl*@hoekstra-uitgeverij.nl (Richard
Bos) wrote in comp.lang.c:
ga*****@yin.interaccess.com (Kenny McCormack) wrote:
In article <dn**********@chessie.cirr.com>,
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote:
Johny <in********@gmail.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.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.


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.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Dec 14 '05 #19

P: n/a
In article <s0********************************@4ax.com>,
Jack Klein <ja*******@spamcop.net> wrote:
....
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.

Dec 14 '05 #20

P: n/a
"Chuck F. " <cb********@yahoo.com> writes:
Kenny McCormack wrote:
Chuck F. <cb********@worldnet.att.net> wrote:
....
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?


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


Kenny McCormack appears to be impervious to reason; replying to his
posts is a waste of time. In other words, please don't feed the
troll.

And welcome back, Chuck.

--
Keith Thompson (The_Other_Keith) ks***@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.
Dec 14 '05 #21

P: n/a
Mark McIntyre <ma**********@spamcop.net> writes:
On 13 Dec 2005 01:56:25 -0800, in comp.lang.c , "arun"
<ar*****@gmail.com> wrote:
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.


The word "initialization" is often used informally to refer to
assigning an initial value to a variable. The usage isn't strictly
consistent with the standard, but I think we recently saw a case where
the standard itself uses the word in this informal sense (I don't
remember the details).

--
Keith Thompson (The_Other_Keith) ks***@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.
Dec 14 '05 #22

P: n/a

Kenny McCormack wrote:
In article <dn**********@chessie.cirr.com>,
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote:
Johny <in********@gmail.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.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).



well kenny thts a whole bag of bull shit

Dec 14 '05 #23

P: n/a

Mark McIntyre wrote:
On 13 Dec 2005 01:56:25 -0800, in comp.lang.c , "arun"
<ar*****@gmail.com> wrote:
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.
----== 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 =----


No i meant initialize itself.so you are saying i cant initialize a
pointer?

Dec 14 '05 #24

P: n/a

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.


hey kenny there is something called learning experience.you have to
"educate" as many newbies as you can.If you cant why the hell r you
arguing with christopher?????
I believe he is doing a splendid job.

Dec 14 '05 #25

P: n/a
Keith Thompson wrote:
.... snip ...
Kenny McCormack appears to be impervious to reason; replying to his
posts is a waste of time. In other words, please don't feed the
troll.

And welcome back, Chuck.


Thanks. Had come to that conclusion, and he has earned the honor
of being the first entry in my c.l.c plonk file.

--
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.
http://www.schneier.com/blog/archive...drm_rootk.html
Dec 14 '05 #26

P: n/a
arun <ar*****@gmail.com> wrote:
well kenny thts a whole bag of bull (expletive deleted)


I assure you that we are all well aware of that fact. Please don't
feed the troll.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Dec 14 '05 #27

P: n/a
In article <dn**********@chessie.cirr.com>,
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote:
arun <ar*****@gmail.com> wrote:
well kenny thts a whole bag of bull (expletive deleted)


I assure you that we are all well aware of that fact. Please don't
feed the troll.


Agreed. Non-orthodoxy is so terrifying to the high-priests.

Dec 14 '05 #28

P: n/a
On 13 Dec 2005 21:06:21 -0800, in comp.lang.c , "arun"
<ar*****@gmail.com> wrote:
No i meant initialize itself.so you are saying i cant initialize a
pointer?


Of course you can, but your question was pretty unclear. You said you
had a pointer to an array of ints, and you wanted to initalise it with
pointers. That doesn't make sense to me.

This is initialisation:

// initalise x to 4
int x = 4;

// initalise px to the address of x
int *px = &x;
----== 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 =----
Dec 14 '05 #29

P: n/a
Chuck F. wrote:
Kenny McCormack wrote:

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.


Of course it is. Understand that Kenny just wants to cause trouble on
the newsgroup.
Brian

--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
Dec 14 '05 #30

P: n/a
In article <40*************@individual.net>,
Default User <de***********@yahoo.com> wrote:
Chuck F. wrote:
Kenny McCormack wrote:

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


Of course it is. Understand that Kenny just wants to cause trouble on
the newsgroup.


Yes, in the sense that observing and commenting upon the idiocy of some of
the "regulars" could be interpreted as "causing trouble". Yes, agreed.

Dec 14 '05 #31

P: n/a
Jack Klein <ja*******@spamcop.net> wrote:
On Tue, 13 Dec 2005 16:19:53 GMT, rl*@hoekstra-uitgeverij.nl (Richard
Bos) wrote in comp.lang.c:
ga*****@yin.interaccess.com (Kenny McCormack) wrote:
In article <dn**********@chessie.cirr.com>,
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote:
>Johny <in********@gmail.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.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.


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


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 would I, were his random interspersions of "Off-topic blah" always
correct. They aren't always, and where they're not, they're actively
harmful, and should be corrected.

Note that in this case, though, my main intent was to support
Christopher (by pointing out that Kenny's remark was irrelevant), not to
contradict Kenny /per se/.

Richard
Dec 15 '05 #32

This discussion thread is closed

Replies have been disabled for this discussion.