Why do people call addresses "pointers"?

T

TTroy

Hi,

I'm just wondering why people/books/experts say "the function returns a
pointer to.." or "we have to send scanf a pointer to.." instead of "the
function returns the address of.." or "we have to send scanf the
address of.."

Isn't the lvalue called a POINTER TO and the (r)value called the
ADDRESS OF?

Why do people refer to the (r)values moving around in a program as
pointers? (Am I missing something, or just reading too much into a
non-issue?)

[I've noticed that experts almost never say "address of", but often
time beginners do... there must be something to it]
 
R

Richard Tobin

TTroy said:
I'm just wondering why people/books/experts say "the function returns a
pointer to.." or "we have to send scanf a pointer to.." instead of "the
function returns the address of.." or "we have to send scanf the
address of.."

Pointer is just a more abstract term, while address is more
implementational. You could for example implement C in some other
language without an access to real addresses, by using indexes into a
large array as pointers.
[I've noticed that experts almost never say "address of", but often
time beginners do... there must be something to it]

The C standard (in most places) uses the term "pointer".

-- Richard
 
D

dandelion

TTroy said:
Hi,

I'm just wondering why people/books/experts say "the function returns a
pointer to.." or "we have to send scanf a pointer to.." instead of "the
function returns the address of.." or "we have to send scanf the
address of.."

AFAIK "pointer" is a logical construct, which is usually (in C) resolved
into an adress. For most C compilers the two terms are equivalent, but this
is not always the case. Specifically all kinds of segment constructions can
fuzzify the issue.
Isn't the lvalue called a POINTER TO and the (r)value called the
ADDRESS OF?
Nope.

Why do people refer to the (r)values moving around in a program as
pointers? (Am I missing something, or just reading too much into a
non-issue?)

I suspect the latter.
[I've noticed that experts almost never say "address of", but often
time beginners do... there must be something to it]

Address of is clearer, but not always correct.
 
J

j

TTroy said:
Hi,

I'm just wondering why people/books/experts say "the function returns a
pointer to.." or "we have to send scanf a pointer to.." instead of "the
function returns the address of.." or "we have to send scanf the
address of.."

Isn't the lvalue called a POINTER TO and the (r)value called the
ADDRESS OF?

The value of an expression can be an address, yes. But just what does
that tell you about the type of the value?

An lvalue is not necessarily a pointer. Consider the following,

int foo;

foo = 10;

Is foo a pointer?
If you answered ``yes'', then I recommend you buy a book on C.
 
T

TTroy

subject of post clearly established above

a question asked about the subject
The value of an expression can be an address, yes. But just what does
that tell you about the type of the value?

An lvalue is not necessarily a pointer. Consider the following,

int foo;

foo = 10;

Is foo a pointer?

totally unrelated question above
If you answered ``yes'', then I recommend you buy a book on C.

The subject of my post was pointers to & addresses of.
Why are you presenting me with a question about an int variable?
Several years ago I did read a book that told me that the "context" of
a statement or sentence affects it's meaning. Have you read any
similar books?
 
J

j

TTroy said:
subject of post clearly established above


a question asked about the subject


totally unrelated question above


The subject of my post was pointers to & addresses of.
Why are you presenting me with a question about an int variable?
Several years ago I did read a book that told me that the "context" of
a statement or sentence affects it's meaning. Have you read any
similar books?

You are not good at this reading business are you?
The point of that was even though a pointer to an object
may be used as an lvalue, not all lvalues are a pointer
to an object. ``foo'' is an object with an object type of ``int''
and is not a pointer to such an object.

This answers your question ``Isn't the lvalue called a POINTER TO''
 
C

Clark S. Cox III

You are not good at this reading business are you?

I think it may be you that needs to brush up on reading comprehension.
The point of that was even though a pointer to an object
may be used as an lvalue, not all lvalues are a pointer
to an object. ``foo'' is an object with an object type of ``int''
and is not a pointer to such an object.

This answers your question ``Isn't the lvalue called a POINTER TO''

Again, you've totally missed the context that the OP provided. That
question was *only* withing the context of pointers and addresses.
Though, of course, the answer turned out to be "no", your answer is
totally irrelevant.

To help you understand the OP's question, you can break it into the
following two questions:
1) When a pointer or address is used as an lvalue, is it called a "pointer"?
2) When a pointer or address is used as a non-lvalue, is it called an
"address"?

(This doesn't change the answer
 
C

Chris Torek

I'm just wondering why people/books/experts say "the function returns a
pointer to.." or "we have to send scanf a pointer to.." instead of "the
function returns the address of.." or "we have to send scanf the
address of.."

Isn't the lvalue called a POINTER TO and the (r)value called the
ADDRESS OF?

No.

Suppose I write:

sizeof(int *)

What is the parenthesized "int *" here? Is it an lvalue? Is it an
rvalue?

The last two questions can be safely answered with "no" and "no"
respectively -- it is neither an lvalue nor an rvalue. The answer
to the first question is that it is a type-name. The type named is
"pointer to int".

What a pointer *is*, then, is part of a type-name. Formally,
a variable (object) of type "int *" holds a value of type "int *":

int *p;
...
p = <some expression>

The <expression> here must have type "pointer to int", or be directly
convert-able to that type, e.g., from malloc():

p = malloc(N * sizeof *p); /* get room for N items */

(here we have a value of type "void *" on the right hand side of
the "=" assignment operator, and "void *" can be converted to "int *").

Simple textbook examples generally start with something like:

int i;
int *p;
...
p = &i;

Here the unary "&" (or "address-of") operator "takes the address"
of the ordinary variable "i", producing a value of type "pointer
to int", pointing to i.

If we then write either:

ret = scanf("%d", p);
or: ret = scanf("%d", &i);

the same thing happens in both cases: scanf() gets, as its second
value, the address of the variable "i": a value of type "pointer
to int", pointing to "i". (The first value is the address of the
first element of the array holding the sequence {'%', 'd', '\0'},
which is a value of type "char *".)

All values in C always have types. Most of the time, when we speak
or write informally, we believe that both the speaker/writer and
listener/reader already understand this and agree as to all the
types, so we just talk about the "value part" of the <type,value>
pair. That is, we do not go around saying:

start i at int 0, then add int 1 each trip through the loop

We omit the "int" part each time. If we do the same with pointers,
we might start with something like:

scanf("%d", &i)

call scanf, passing as the first value a value of type "char *"
pointing to the percent sign in the three-character array holding
the %d format directive, and passing as the second value a value
of type "int *" pointing to the local variable named "i"

(the full, formal version) and end up with:

call scanf with a pointer to "i"

or even more colloquially:

give scanf the address of "i"

but these all *mean* the same thing.
Why do people refer to the (r)values moving around in a program as
pointers? (Am I missing something, or just reading too much into a
non-issue?)

I think the last. :)
[I've noticed that experts almost never say "address of", but often
time beginners do... there must be something to it]

I prefer to reserve the term "address of" for the unary-& operator
myself, but this is something of a matter of taste.
 
J

j

Clark S. Cox III said:
I think it may be you that needs to brush up on reading comprehension.


Again, you've totally missed the context that the OP provided. That
question was *only* withing the context of pointers and addresses.
Though, of course, the answer turned out to be "no", your answer is
totally irrelevant.

To help you understand the OP's question, you can break it into the
following two questions:
1) When a pointer or address is used as an lvalue, is it called a "pointer"?
2) When a pointer or address is used as a non-lvalue, is it called an
"address"?

(This doesn't change the answer

I inferred from what he said not from what he meant to say.

Suppose we did have some function that returned a pointer
to some object, then the value it returns is the value of that
expression.

If we pass a pointer to some object to scanf, we also have
a value of an expression in this context too. Whether this
value is then used as an lvalue within scanf is irrelevant to
what he asked.

From this, he follows with the question of ``isn't an lvalue a pointer to''.
lvalues are in a completely different context from what he was
previously talking about. lvalues designate objects! This has absolutely
nothing to do with values of expressions. As such, my response stands
relevant to the question ``isn't an lvalue a pointer to''. It is not my
problem if he is incapable of expressing himself with the English
language.
 
T

TTroy

j said:
Clark S. Cox III said:
I inferred from what he said not from what he meant to say.

Suppose we did have some function that returned a pointer
to some object, then the value it returns is the value of that
expression.

If we pass a pointer to some object to scanf, we also have
a value of an expression in this context too. Whether this
value is then used as an lvalue within scanf is irrelevant to
what he asked.

From this, he follows with the question of ``isn't an lvalue a pointer to''.
lvalues are in a completely different context from what he was
previously talking about. lvalues designate objects! This has absolutely
nothing to do with values of expressions. As such, my response stands
relevant to the question ``isn't an lvalue a pointer to''. It is not my
problem if he is incapable of expressing himself with the English
language.

If you had told me that I'm inexperienced with C, and I would take it
as constructive criticism. Instead you go an talk about my lack of
English skills. Are you trying to prove to the world that you're the
biggest idiot alive with your comments? For your information, I speak
know 4 languages and English isn't my first. Nevertheless, I find it
ridiculous that someone of your intelligence is rating my English
skills, when it is you who's a little deficient upstairs.

English (and most other languages) is built on the idea of using
"contexts" to infer meanings of sentences/phrases/paragraphs/etc. Why
do you think a book has: a title, chapters(with more titles), sections
within chapters, paragraphs within sections, sentences withing
paragraphs? One doesn't hold the meaning of a sentence based solely on
just that sentence. That would mean every book would be 10 000+ pages
long with constant repetition.

Who in their right mind will start off a topic talking about pointers &
addresses, mention a sentence about lvalues/rvalues of pointers and
then mention an unrelated sentence about lvalues/rvalues right after
it? Do you do that type of thing in your writing? My niece in grade 2
can figure out that the second sentence that refers to lvalues/rvalues
is "connected" to the previous sentence that also mentions
lvalues/rvalues (which has a direct link with pointers & addresses
established in it).

"The bears loved to eat berries from the ABC trees."
"They always ate them fresh off the trees, never stored them for
later."

My niece knows exactly what the second sentence is referring to. You're
probably reading it thinking: "Who is they? What is them? Which trees?"

On a similar note:
==================
Why does the English language have pronouns? So you're telling me,
every sentence you read that has the words "her", "it", "that" make no
sense to you? Those authors must have poor English skills, right? You
must only read those 10 000+ page books where everything is repeated
explicity.

By the way, did you notice the title of my original post? Well that
doesn't matter, each sentence has an isolated meaning, right?
 
J

j

TTroy said:
<snipped babbling>

You went from talking about values of expressions and
why they may be referred to as ``pointer to..'' or ``an address''
to asking ``isn't the lvalue a pointer to?''. Your first question
had nothing to do with lvalues. Which I have already explained.
You are asking a separate question about whether an lvalue
is a ``pointer to''. My counter-example showed that an lvalue
does not necessarily mean ``pointer to''. You can certainly
use a pointer to a valid object as an lvalue but this does not
imply that all lvalues are a pointer to some object.
 
T

TTroy

j said:
TTroy said:
<snipped babbling>
You went from talking about values of expressions and
why they may be referred to as ``pointer to..'' or ``an address''
to asking ``isn't the lvalue a pointer to?''. Your first question
had nothing to do with lvalues.

You say my first question had nothing to do with lvalues. You're a
genius.
Which I have already explained.
You are asking a separate question about whether an lvalue
is a ``pointer to''. My counter-example showed that an lvalue
does not necessarily mean ``pointer to''. You can certainly
use a pointer to a valid object as an lvalue but this does not
imply that all lvalues are a pointer to some object.

Why do you insist on adding proof to my claim that you're a high
calibre idiot?
Your writing is horrible, and you sure as heck can't read.

The first question in my post was: "Isn't the lvalue called a POINTER
TO and the (r)value called the ADDRESS OF?"

Before that I had a paragraph that builds the context up before I
unleashed the question(and the title helped too). And even to let the
marginally retarted like you know that the question was related to
previous context, I used "the lvalue" instead of "a lvalue." That
"the" links that sentence strongly with the previous one, but even with
an "a" there, an average idiot could have figured out the connection.
But as you've shown, you're no average idiot.

In your most recent response (above), you say that my first question
had nothing to do with lvalues. So I wonder what the word "lvalue" in
the question was placed there for? Maybe I'm as dumb as you, so I just
plugged that word in for no reason, knowing that seasoned veterans of
idiocy will just ignore it.

I can't believe you're still responding and increasing your status as a
top quality idiot.
 
J

j

TTroy said:
You say my first question had nothing to do with lvalues. You're a
genius.


Why do you insist on adding proof to my claim that you're a high
calibre idiot?
Your writing is horrible, and you sure as heck can't read.

The first question in my post was: "Isn't the lvalue called a POINTER
TO and the (r)value called the ADDRESS OF?"

Before that I had a paragraph that builds the context up before I
unleashed the question(and the title helped too). And even to let the
marginally retarted like you know that the question was related to
previous context, I used "the lvalue" instead of "a lvalue." That
"the" links that sentence strongly with the previous one, but even with
an "a" there, an average idiot could have figured out the connection.
But as you've shown, you're no average idiot.

In your most recent response (above), you say that my first question
had nothing to do with lvalues. So I wonder what the word "lvalue" in
the question was placed there for? Maybe I'm as dumb as you, so I just
plugged that word in for no reason, knowing that seasoned veterans of
idiocy will just ignore it.

I can't believe you're still responding and increasing your status as a
top quality idiot.

To quote you,
``I'm just wondering why people/books/experts say "the function returns a
pointer to.." or "we have to send scanf a pointer to.." instead of "the
function returns the address of.." or "we have to send scanf the
address of.." '' ...

.... is a question in itself. Even without an explicit question mark.
Which means that it is your initial question. So what is the problem?

In fact, observe the other responses to your initial post. This question
was the first one addressed. :)

Why do you think that is?

Oh, look at the inclusion of the word ``why'' near the start of that
sentence.
What do you think that conveys to the reader?

Additionally, your use of ``the lvalue'' is referring to the concept here
not to anything relating to your initial question. Unless you can provide
reasoning as to how your initial question had anything to do with
an lvalue. I suspect that you cannot.
 
T

TTroy

j said:
To quote you,
``I'm just wondering why people/books/experts say "the function returns a
pointer to.." or "we have to send scanf a pointer to.." instead of "the
function returns the address of.." or "we have to send scanf the
address of.." '' ...

... is a question in itself. Even without an explicit question mark.
Which means that it is your initial question. So what is the problem?

The first sentence could be taken as a "call for a response," but it's
not a question. It could be considered "similar" to a "question" if it
wasn't followed by an actual question that triggered the context that
the first sentenced built up. Since I used a question to connect to
the previous context, most people would not consider the first sentence
as an independent "call for a response" (it's not a question period!).

In fact, observe the other responses to your initial post. This question
was the first one addressed. :)

Why do you think that is?

What is your point? You responded to the actual first question, not
the first sentence (go and check).
Oh, look at the inclusion of the word ``why'' near the start of that
sentence.

What does this sentence mean to you? : "He wonders 'why' idiots don't
stop."
Is that a question? It uses the word "why!!!"

How about this sentence? : "It doesn't matter 'when' he'll understand
he's an idiot, he's only out to prove supremacy in his field of
idiocy."
Is that a question? It uses the word "when!!!"
What do you think that conveys to the reader?

Depends on whether or not the reader was a supreme idiot. Since I
didn't intend for my target audience to include idiots, most that
responded understood fine, except this one individual.
Additionally, your use of ``the lvalue'' is referring to the concept here
not to anything relating to your initial question. Unless you can provide
reasoning as to how your initial question had anything to do with
an lvalue. I suspect that you cannot.

English is my 4th language, and let me guess, it must be your 10+th?
What are you talking about in the passage above? What do you mean by
"here." You're using the word "here" without any sort of proper
context for it built up, and you complain about my lack of clarity.

I'm a mechanical engineer trying to learn the ins/outs of C. Just
because you're more familiar with C than me, that doesn't give you the
right to bash anything but my C skills (like my English).
 
J

j

TTroy said:
The first sentence could be taken as a "call for a response," but it's
not a question. It could be considered "similar" to a "question" if it
wasn't followed by an actual question that triggered the context that
the first sentenced built up. Since I used a question to connect to
the previous context, most people would not consider the first sentence
as an independent "call for a response" (it's not a question period!).



What is your point? You responded to the actual first question, not
the first sentence (go and check).


What does this sentence mean to you? : "He wonders 'why' idiots don't
stop."
Is that a question? It uses the word "why!!!"

Different context. I referred you to your initial question which
included ``why'' near the start of the sentence. You are making
an inquiry as to the reasoning behind calling ``addresses'',
``pointers''.
How about this sentence? : "It doesn't matter 'when' he'll understand
he's an idiot, he's only out to prove supremacy in his field of
idiocy."
Is that a question? It uses the word "when!!!"

Different context.
Depends on whether or not the reader was a supreme idiot. Since I
didn't intend for my target audience to include idiots, most that
responded understood fine, except this one individual.

I think your excessive use of the word ``idiot'' makes youl ook foolish.
You aren't showing incontravertibly that, that is true. So it has no
bearing. :)
English is my 4th language, and let me guess, it must be your 10+th?
Irrelevant.

What are you talking about in the passage above? What do you mean by
"here." You're using the word "here" without any sort of proper
context for it built up, and you complain about my lack of clarity.

It was written in response to your post. The post I was responding
to serves as providing proper context. If I were to exclude your
post from my response, then I would not be providing proper
context.
I'm a mechanical engineer trying to learn the ins/outs of C.

I don't care.
Just
because you're more familiar with C than me, that doesn't give you the
right to bash anything but my C skills (like my English).

Oh stop your bloody whinging. It is really off-topic for this newsgroup.
The main point here is that your initial question,

``I'm just wondering why people/books/experts say "the function returns a
pointer to.." or "we have to send scanf a pointer to.." instead of "the
function returns the address of.." or "we have to send scanf the
address of.." '' ...

.... has absolutely nothing to do with lvalues. What part of that do you not
understand? So relating your second question to the first in this regard,
is absolutely meaningless. Try and answer this question again, since
you completely ignored it in your response. I asked you, to what lvalue
were you referring to?

I'll make it extremely simple for you.

First question,
``I'm just wondering why people/books/experts say "the function returns a
pointer to.." or "we have to send scanf a pointer to.." instead of "the
function returns the address of.." or "we have to send scanf the
address of.." ''

Second question,
``Isn't the lvalue called a POINTER TO and the (r)value called the
ADDRESS OF?''

Where is the lvalue that you are referring to in the first question?
I see no such lvalue mentioned.
 
E

E. Robert Tisdale

TTroy said:
I'm just wondering why people/books/experts say
"the function returns a pointer to.." or
"we have to send scanf a pointer to.." instead of
"the function returns the address of.."
or "we have [must] address of.."

Isn't the lvalue called a POINTER TO
and the (r)value called the ADDRESS OF?

Why do people refer to the (r)values moving around in a program
as pointers?
(Am I missing something?
Or just reading too much into a non-issue?)
Probably.

[I've noticed that experts almost never say "address of",
but often time beginners do. There must be something to it]

Pointers are objects
and the values that they contain are addresses.
The representation of addresses is implementation dependent.
They may be [virtual] memory addresses.

int i = 0;
int* p = &i;

p is a pointer to an object of type int.
&i is the address of an object of type int.


void f(int* p);
f(p); // passes a pointer to f(int*)
f(&i) // passes an address to f(int*)

But, since p == &i, it might be correct to say either one.
 
B

Big K

j said:
Different context. I referred you to your initial question which
included ``why'' near the start of the sentence. You are making
an inquiry as to the reasoning behind calling ``addresses'',
``pointers''.


Different context.


I think your excessive use of the word ``idiot'' makes youl ook foolish.
You aren't showing incontravertibly that, that is true. So it has no
bearing. :)
10+th?

It was written in response to your post. The post I was responding
to serves as providing proper context. If I were to exclude your
post from my response, then I would not be providing proper
context.


I don't care.


Oh stop your bloody whinging. It is really off-topic for this newsgroup.
The main point here is that your initial question,

``I'm just wondering why people/books/experts say "the function returns a
pointer to.." or "we have to send scanf a pointer to.." instead of "the
function returns the address of.." or "we have to send scanf the
address of.." '' ...

... has absolutely nothing to do with lvalues. What part of that do you not
understand? So relating your second question to the first in this regard,
is absolutely meaningless. Try and answer this question again, since
you completely ignored it in your response. I asked you, to what lvalue
were you referring to?

I'll make it extremely simple for you.

First question,
``I'm just wondering why people/books/experts say "the function returns a
pointer to.." or "we have to send scanf a pointer to.." instead of "the
function returns the address of.." or "we have to send scanf the
address of.." ''

Second question,
``Isn't the lvalue called a POINTER TO and the (r)value called the
ADDRESS OF?''

Where is the lvalue that you are referring to in the first question?
I see no such lvalue mentioned.

Ok guys, stop clogging up the internet with these posts (the backbone
routers are sweating).

As for the argument, I think you(j) totally misunderstood the original
post. I have no idea how you thought a sentence in the middle of the
post was unrelated to the subject at hand.

I was going to respond to the original post, but Chris Torek posted an
answer 10 times better than mine.
 
J

j

Big K said:
Ok guys, stop clogging up the internet with these posts (the backbone
routers are sweating).

As for the argument, I think you(j) totally misunderstood the original
post. I have no idea how you thought a sentence in the middle of the
post was unrelated to the subject at hand.

I was going to respond to the original post, but Chris Torek posted an
answer 10 times better than mine.

It is simple. What is the lvalue that he is referring to?
 
M

Mike Wahler

TTroy said:
Hi,

I'm just wondering why people/books/experts say "the function returns a
pointer to.." or "we have to send scanf a pointer to.." instead of "the
function returns the address of.." or "we have to send scanf the
address of.."

Isn't the lvalue called a POINTER TO and the (r)value called the
ADDRESS OF?

Why do people refer to the (r)values moving around in a program as
pointers? (Am I missing something, or just reading too much into a
non-issue?)

[I've noticed that experts almost never say "address of", but often
time beginners do... there must be something to it]

A pointer is an object. An address is a value.
A pointer object can store the value of an address.
This address value becomes the pointer object's value.
People will use often 'pointer' and 'address' interchangeably,
but technically a function would return an 'address
value', which can be stored in a pointer type object.

-Mike
 

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

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top