Array name as pointers

N

newgoat

As far as I understand, in "int arr[10]", the name of the integer array
"arr"
is equivalent to the pointer to the first element of the array. But is
"arr"
really a pointer, identical as "int *arr;" ?

I tried to modify this "arr" thing in the following code. GCC warns
me of incompatible pointers, which I have no idea of.

---------------------------------------------------------------
#include<stdio.h>

void incrementPtr(int **);

int main(int argc, char *argv[]){
int i;
int a[3] = {10, 20, 30};

incrementPtr(&a);

for(i = 0; i < 3; i++){
printf("a[%d] = %d\n", i, *(a + i));
}

return 0;
}

void incrementPtr(int **a){
*a++;
}
-------------------------------------------------

Anyone has any opinion why I got the warning? And
if "a" in this code can be modified?

Thanks.
 
M

Martin Ambuhl

newgoat said:
As far as I understand, in "int arr[10]", the name of the integer array
"arr"
is equivalent to the pointer to the first element of the array. But is
"arr"
really a pointer, identical as "int *arr;" ?

No. This question is so dead and boring it makes the parrot look
lively. Do you imagine you are the first with this thought? It is to
avoid repeatedly answering such things that we have a FAQ
<http://c-faq.com/>. Please check it before posting.
Among others, you might find interesting:

<http://c-faq.com/aryptr/aryptr2.html> But I heard that char a[] was
identical to char *a.

<http://c-faq.com/aryptr/aryptrequiv.html> So what is meant by the
``equivalence of pointers and arrays'' in C?

<http://c-faq.com/aryptr/aryptrparam.html> If they're so different, then
why are array and pointer declarations interchangeable as function
formal parameters?

[...]
Anyone has any opinion why I got the warning? And
if "a" in this code can be modified?

Once you check the FAQ, as you should have already done, you will know
the answer.
 
R

Rod Pemberton

Martin Ambuhl said:
newgoat said:
As far as I understand, in "int arr[10]", the name of the integer array
"arr"
is equivalent to the pointer to the first element of the array. But is
"arr"
really a pointer, identical as "int *arr;" ?

No.

Fair statement.
This question is so dead and boring it makes the parrot look
lively.

? I admit I'm asleep right now, but WTF did you forget?
Do you imagine you are the first with this thought?
Hostility.

It is to
avoid repeatedly answering such things that we have a FAQ
<http://c-faq.com/>. Please check it before posting.
Among others, you might find interesting:

<http://c-faq.com/aryptr/aryptr2.html> But I heard that char a[] was
identical to char *a.

<http://c-faq.com/aryptr/aryptrequiv.html> So what is meant by the
``equivalence of pointers and arrays'' in C?

<http://c-faq.com/aryptr/aryptrparam.html> If they're so different, then
why are array and pointer declarations interchangeable as function
formal parameters?

Fair. Fair. Fair and Fair.
[...]
Anyone has any opinion why I got the warning? And
if "a" in this code can be modified?

Once you check the FAQ ... you will know
the answer.

Fair.

Once you check the FAQ, as you should have already done,

How could he know about the FAQ before you told him? Is he prescient? I
thought that was only for God. And, I think it violates a number of laws of
communication theory too.


Rod Pemberton
 
S

Skarmander

Rod said:
Martin Ambuhl said:
newgoat said:
As far as I understand, in "int arr[10]", the name of the integer array
"arr"
is equivalent to the pointer to the first element of the array. But is
"arr"
really a pointer, identical as "int *arr;" ?
No.

Fair statement.
This question is so dead and boring it makes the parrot look
lively.

? I admit I'm asleep right now, but WTF did you forget?
He is assuming a shared cultural heritage of geek, where everybody knows
Monty Python's dead parrot sketch. It should come as no surprise that
Wikipedia has a full article on it: http://en.wikipedia.org/wiki/Dead_Parrot.

I must say I've seen kinder wordings of "read the FAQ".

S.
 
R

Richard G. Riley

newgoat said:
As far as I understand, in "int arr[10]", the name of the integer array
"arr"
is equivalent to the pointer to the first element of the array. But is
"arr"
really a pointer, identical as "int *arr;" ?

No. This question is so dead and boring it makes the parrot look
lively. Do you imagine you are the first with this thought? It is to
avoid repeatedly answering such things that we have a FAQ
<http://c-faq.com/>. Please check it before posting.

I assume you will be as rude to everyone else in this NG whose
questions are already answered in the FAQ and the Ansi Standard? Since
that's about 99.9% of them (since we're constantly told you cant ask
programming questions here - only pure C ones), then I suspect you'll
be a busy little bee.

Wouldn't it have been so much nicer of you to say:

"Good morning, this issue confuses a lot of C prgroammers. Here is a
link to the FAQ which might help".

Because one thing is common knowledge and "boring" to you, doesnt mean
it is to someone new who comes here for help. If that is your attitude
then I suggest you don't bother trying to help.

Have a good day now
 
J

John Bode

Richard said:
newgoat said:
As far as I understand, in "int arr[10]", the name of the integer array
"arr"
is equivalent to the pointer to the first element of the array. But is
"arr"
really a pointer, identical as "int *arr;" ?

No. This question is so dead and boring it makes the parrot look
lively. Do you imagine you are the first with this thought? It is to
avoid repeatedly answering such things that we have a FAQ
<http://c-faq.com/>. Please check it before posting.

I assume you will be as rude to everyone else in this NG whose
questions are already answered in the FAQ and the Ansi Standard?

God, I hope so.
Since
that's about 99.9% of them (since we're constantly told you cant ask
programming questions here - only pure C ones), then I suspect you'll
be a busy little bee.

The focus of this newsgroup is the C programming language, not
applications that just happen to be written in C. Why is that so hard
for people to understand?
Wouldn't it have been so much nicer of you to say:

"Good morning, this issue confuses a lot of C prgroammers. Here is a
link to the FAQ which might help".

Because one thing is common knowledge and "boring" to you, doesnt mean
it is to someone new who comes here for help. If that is your attitude
then I suggest you don't bother trying to help.

Have a good day now

I've been following this newsgroup since around 1994, and I have to
say, after 12 years of people asking the same exact questions the same
exact way, it's hard to stay civil. And people have good days and bad
days; I've seen Martin be just as pleasant as you wished everyone would
be.

It is simply a part of usenet etiquette to lurk a while, see if your
question has already been addressed (through the wonders of Google
search), and read the newsgroup FAQ if one exists. Given that the FAQ
for this particular newsgroup gets posted twice a month, it's not
entirely unreasonable to be annoyed when someone asks a question that
it addresses.

It's also hard to stay pleasant with all the self-appointed 'net
nannies boo-hooing about how *rude* we're all being.
 
R

Richard G. Riley

newgoat wrote:
As far as I understand, in "int arr[10]", the name of the integer array
"arr"
is equivalent to the pointer to the first element of the array. But is
"arr"
really a pointer, identical as "int *arr;" ?

No. This question is so dead and boring it makes the parrot look
lively. Do you imagine you are the first with this thought? It is to
avoid repeatedly answering such things that we have a FAQ
<http://c-faq.com/>. Please check it before posting.

I assume you will be as rude to everyone else in this NG whose
questions are already answered in the FAQ and the Ansi Standard?

God, I hope so.

Then you need to step back and reconsider.
The focus of this newsgroup is the C programming language, not
applications that just happen to be written in C. Why is that so hard
for people to understand?

What was not "C" in the OP?
I've been following this newsgroup since around 1994, and I have to

The old "long term service medal" does not wash. Sorry.
say, after 12 years of people asking the same exact questions the same
exact way, it's hard to stay civil. And people have good days and
bad

Then dont respond. Let someone else who is less bored respond. By your
rational there is no need for beginners guides because C has been
around for so long.
days; I've seen Martin be just as pleasant as you wished everyone would
be.

So what? Was he here? Sorry, but that doesnt in any way justify his
reply to someone who came here in good faith looking for help. The
first name terms suggest a certain affiliation with him : this is
maybe the type of clique to which I referred.
It is simply a part of usenet etiquette to lurk a while, see if your

For you. Some people come hre to get an answer and then depart. If you
dont want to , or cant, help the ignore if you have nothing civil to say.

question has already been addressed (through the wonders of Google
search), and read the newsgroup FAQ if one exists. Given that the FAQ
for this particular newsgroup gets posted twice a month, it's not
entirely unreasonable to be annoyed when someone asks a question that
it addresses.

It is totally unreasonable. Not everyone is here for a month "lurking"
before they post. Not all usenet servers duplicate all posts.
It's also hard to stay pleasant with all the self-appointed 'net
nannies boo-hooing about how *rude* we're all being.

The last paragraph is particularly telling.

Its really simple : if you can and want to then "help". If not,
dont. There is nothing that ruins a thread more than the usual
suspects piling in with their "read the fucking FAQ" type posts when
other more tolerant posters have posted a link or help directly.

If you dont't see that that you should take a break.
 
R

RSoIsCaIrLiIoA

I've been following this newsgroup since around 1994, and I have to
say, after 12 years of people asking the same exact questions the same
exact way, it's hard to stay civil. And people have good days and bad
days; I've seen Martin be just as pleasant as you wished everyone would
be.

It is simply a part of usenet etiquette to lurk a while, see if your
question has already been addressed (through the wonders of Google
search), and read the newsgroup FAQ if one exists.

and if *all* the questions were "been addressed" ?
in that case why to write and answer one more time? :)
 
M

Martin Ambuhl

Richard said:
I assume you will be as rude to everyone else in this NG whose
questions are already answered in the FAQ and the Ansi Standard?

It is rude beyond belief to post in a newsgroup questions answered in
the FAQ. It is strange to find the even ruder "Richard G. Riley"
thinking that pointing out that posters should have checked the FAQ is
rude.
 
R

Richard G. Riley

It is rude beyond belief to post in a newsgroup questions answered in
the FAQ. It is strange to find the even ruder "Richard G. Riley"
thinking that pointing out that posters should have checked the FAQ is
rude.

I think you should go back and see what you wrote "Martin".

The fact that you think think the FAQ is accessible to or even known
to newbies who come here says more about you than it does the newcomer
who comes here in the earnest hope of finding some help.

Did it even cross your mind that not all usenet users have web access?

Did it ever even cross your mind that a newbie might not even know
what to look for in the FAQ? Probably not.

You did not point him to the FAQ : you tried to make him look like an
incompetent idiot for not having (a) known about it and (b) not having
used it. I wont bother quoting you : it's all in the thread.

Interestingly enough there was a long enough thread reently about
similar stuff with pointers and arrays : I noticed you didnt come
haranging some of the regulars who were contributing then.

So to sum up : help or dont help. You chose the later but in a more
condescending and negative way than simply ignoring the poster or just
pointing him amicably to the correct section in the FAQ.
 
S

santosh

Martin said:
It is rude beyond belief to post in a newsgroup questions answered in
the FAQ.
<snip>

I don't see anything "rude" much less "rude beyond belief" to post a
FAQ. It's tiresome and exasperating no doubt to long time regulars, but
it's too idealistic to expect every newbie to find *and* check the
entire FAQ before posting. If it's too much for you to take, a better
course would be to simply ignore the poster in question or even
killfile him, (hey it's your newsreader and it's your loss...or gain),
or perhaps send him a private mail, but to insult and ridicule him in a
public newsgroup upon his (possibly) first post is "rude beyond
belief".
 
M

Mark McIntyre

The old "long term service medal" does not wash. Sorry.

And yet every day, /you/ move a step closer to people's killfiles.

No, generally. Why not go read up on it?
It is totally unreasonable.

You presumably have the patience of a saint, and don't mind someone
asking you, "are we nearly there yet" every thirty seconds from about
five minutes after departure. The rest of us are mortals.
Its really simple : if you can and want to then "help". If not,
dont.

He did help. Your posts on the other hand have been useless.
There is nothing that ruins a thread more than the usual
suspects piling in with their "read the fucking FAQ" type posts

Yes, there's plenty. Such as trolls, abusive newbies, idiots, and
incompetents. Frankly, pointing people at hte FAQ is entirely
appropriate.
Mark McIntyre
 
M

Martin Ambuhl

Richard said:
I think you should go back and see what you wrote "Martin".

Assholes who do nothing to help the original poster, telling them
nothing about where the FAQ is, what questions might be relevant, or
what normal postign is should just keep quiet. Some of them, like
"Richard G. Riley", while contributing *nothing* snipe at those who do
help. Yes, you are a rude and ignorant person.
The fact that you think think the FAQ is accessible to or even known
to newbies who come here says more about you than it does the newcomer
who comes here in the earnest hope of finding some help.

This is akin to "Hey, I'm an American. How was I supposed to know you
English drive on the wrong side of the road." A poster old enough to be
posting here is old enough to know what is expected.
Did it even cross your mind that not all usenet users have web access?
Did it ever even cross your mind that a newbie might not even know
what to look for in the FAQ? Probably not.

Did you ever grow a brain? Since when is news.announce.newusers not
accessible to newbies?

You did not point him to the FAQ :

OK. You are a dmanable liar. There are four links to the FAQ,
including three to specific questions pertaining to his problem. It is
now completely clear that you are an antisocial troll who has *no*
interest in the truth. Goodbye.
 
J

John Bode

Richard said:
newgoat wrote:
As far as I understand, in "int arr[10]", the name of the integer array
"arr"
is equivalent to the pointer to the first element of the array. But is
"arr"
really a pointer, identical as "int *arr;" ?

No. This question is so dead and boring it makes the parrot look
lively. Do you imagine you are the first with this thought? It is to
avoid repeatedly answering such things that we have a FAQ
<http://c-faq.com/>. Please check it before posting.

I assume you will be as rude to everyone else in this NG whose
questions are already answered in the FAQ and the Ansi Standard?

God, I hope so.

Then you need to step back and reconsider.

Why? It's just a fracking newsgroup, for frack's sake.
What was not "C" in the OP?

I wasn't responding to the OP, I was responding to your statement that
"you can't ask programming questions here - only pure C ones." You're
too busy being so goddamned offended on other people's behalf to pay
attention to what I'm saying.
The old "long term service medal" does not wash. Sorry.

Quit interrupting. It's *rude*. And you missed the point.
Then dont respond. Let someone else who is less bored respond. By your
rational there is no need for beginners guides because C has been
around for so long.

Hey, guess what? I didn't respond to the OP. I thought Martin had
done an adequate job in that respect. I was responding to *you*.
So what? Was he here? Sorry, but that doesnt in any way justify his
reply to someone who came here in good faith looking for help. The
first name terms suggest a certain affiliation with him : this is
maybe the type of clique to which I referred.

What the hell else am I going to call him? "Mr. Ambuhl?" "His Nibs?"
"That guy? Who wrote that article?" Referring to him by the name he
actually uses for posting here isn't being "cliquey" or familiar.

Jeez.
For you. Some people come hre to get an answer and then depart. If you
dont want to , or cant, help the ignore if you have nothing civil to say.

QUIT INTERRUPTING. IT'S RUDE.

And no, it's *not* just for me. It is accepted usenet etiquette for
*everyone*; you, me, and everyone else. Usenet is not a quickie
reference manual; it is not the place to go when you want an answer
*now*.
It is totally unreasonable. Not everyone is here for a month "lurking"
before they post. Not all usenet servers duplicate all posts.

Which brings us, again, to the wonders of Google, and this wonderful
technology known as "searching the archive." If you're smart enough to
post here in the first place, you're smart enough to do a search.
Google does a pretty damned good job archiving, and you should be able
to find the FAQ easily enough.

Go to comp.lang.c in Google groups, type FAQ in the search box, and
whammo, second link down is the latest FAQ entry.

This is not hard. It's not unreasonable to expect everyone who comes
to this group to first do a search, which will likely get them the
answer they need faster than waiting for a response.
The last paragraph is particularly telling.

Yeah. You're at least forty times more annoying than any random
clueless newbie.
Its really simple : if you can and want to then "help". If not,
dont. There is nothing that ruins a thread more than the usual
suspects piling in with their "read the fucking FAQ" type posts when
other more tolerant posters have posted a link or help directly.

And guess what I didn't do. Again, I was responding to *you*, not the
OP.
If you dont't see that that you should take a break.

Here's my posting history. Tell me how useless I'm being:

http://groups.google.com/group/comp.lang.c/[email protected]&start=0&scoring=d&
 
R

Rod Pemberton

Martin Ambuhl said:
Assholes who do nothing to help the original poster, telling them
nothing about where the FAQ is, what questions might be relevant, or
what normal postign is should just keep quiet. Some of them, like
"Richard G. Riley", while contributing *nothing* snipe at those who do
help. Yes, you are a rude and ignorant person.

Interesting, when I complained about others not contributing anything but
snipe (i.e., CB "PLONK" Falconer, et al) you said nothing... Asshole.
This is akin to "Hey, I'm an American. How was I supposed to know you
English drive on the wrong side of the road." A poster old enough to be
posting here is old enough to know what is expected.

No, from what I can tell about "Martin Ambuhl," it would never cross his
mind.
Did you ever grow a brain? Since when is news.announce.newusers not
accessible to newbies?

Mr. Riley, you forgot to point out to Mr. Ambuhl that usually only moderated
newsgroups have FAQ's.
You did not point him to the FAQ :

OK. You are a dmanable[sic] liar. There are four links to the FAQ,
including three to specific questions pertaining to his problem. It is
now completely clear that you are an antisocial troll who has *no*
interest in the truth. Goodbye.

Good riddance. What no "PLONK?" That's completely uncharacteristic of
you...
 

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
474,176
Messages
2,570,947
Members
47,501
Latest member
Ledmyplace

Latest Threads

Top