473,387 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Trying to understand pointers for function paramaters

Hi all,

I'm trying to understand how pointers for function parameters work. As I
understand it, if you got a function like:

void f(int *i)
{
*i = 0;
}

int main()
{
int a;
f(&a);
return 0;
}

It does what you want (namely altering the value of a).
I find this illogical. As far as I can understand, the address of "a" is
passed, and "*i" is set with this address not "i", as it should be in my
understanding.
What am I missing?
TIA

P.S.
I've really searched for this in the groups faq and elsewhere before I
posted.
Nov 14 '05 #1
51 2479
"Richard Hengeveld" <ri**************@hotmail.com> wrote in
news:41***********************@news.wanadoo.nl:
Hi all,

I'm trying to understand how pointers for function parameters work. As I
understand it, if you got a function like:

void f(int *i)
{
*i = 0;
}

int main()
{
int a;
f(&a);
return 0;
}


Assume that 'a' exist at memory location 0x1000'0000. Now assume 'i' is
located at 0x1000'0004.

Before calling f():
-------------------
C name Mem. Addr. Contents (value located there)
------ ------------ ------------------------------
a 0x1000'0000: ???
i 0x1000'0004: ???

In function f() after the assignment to *i:
-------------------------------------------

C name Mem. Addr. Contents (value located there)
------ ------------ ------------------------------
a 0x1000'0000: 0
i 0x1000'0004: 0x1000'0000

so 'i' is a pointer that contains the value of the address of 'a'. Thus
weh you dereference 'i' via *i you now point to memory location
0x1000'0000. So if you modify what is as 0x1000'0000 then the value of 'a'
will be modified.

Simple, logical.

--
- Mark ->
--
Nov 14 '05 #2
"Richard Hengeveld" <ri**************@hotmail.com> writes:
Hi all,

I'm trying to understand how pointers for function parameters work. As I
understand it, if you got a function like:

void f(int *i)
{
*i = 0;
}

int main()
{
int a;
f(&a);
return 0;
}

It does what you want (namely altering the value of a).
I find this illogical. As far as I can understand, the address of "a" is
passed, and "*i" is set with this address not "i", as it should be in my
understanding.
What am I missing?


Yes, you're passing the address of "a" to the function "f".

Incidentally, "i" is a poor name for the parameter. "i" is commonly
used as a name for an int variable; the parameter is a pointer to int.
It's perfectly legal, but potentially confusing.

In the assignment

*i = 0;

"i" is a pointer, and "*i" is an int object. You're assigning the
value 0 to an int object. Which int object? The one i points to,
which happens to be "a".

If you had written

i = 0;

you'd be assigning a value to "i", which is a pointer object; the
value being assigned would be a null pointer.

It might be clearer if you change the names:

void f(int *ptr_param)
{
*ptr_param = 0;
}

int main(void)
{
int int_object;
f(&int_object);
return 0;
}

(In a real program, of course, variables should generally have names
that reflect what they're used for; for this toy example, it's more
important to show their types.)

--
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.
Nov 14 '05 #3
Richard Hengeveld wrote:


I'm trying to understand how pointers for function parameters work.
As I understand it, if you got a function like:

void f(int* p) {
*p = 0;
}

int main(int argc, char* argv[]) {
int a;
f(&a);
return 0;
}

It does what you want (namely altering the value of a).
I find this illogical. As far as I can understand,
the address of "a" is passed,
and "*p" is set with this address not "p"
as it should be in my understanding.


Probably what is confusing you is the *formal* argument

int* p

This tells you that p is a pointer to an object of type int.
the statement

p = 0;

would assign the address value 0 to p.
The expression

*p

is a *reference* to (another name for) a
so writing

*p = 0;

is the same thing as writing

a = 0;

Nov 14 '05 #4

"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message
news:cj**********@nntp1.jpl.nasa.gov...
Richard Hengeveld wrote:


I'm trying to understand how pointers for function parameters work.
As I understand it, if you got a function like:

void f(int* p) {
*p = 0;
}

int main(int argc, char* argv[]) {
int a;
f(&a);
return 0;
}

It does what you want (namely altering the value of a).
I find this illogical. As far as I can understand,
the address of "a" is passed,
and "*p" is set with this address not "p"
as it should be in my understanding.


Probably what is confusing you is the *formal* argument

int* p


Thanks for replying.
Yes, that is exactly what is confusing me.
I understand you set a pointer (if you're not passing to functions) by:

int a, *p;
p = &a;

and not:

p* = &a

Wouldn't it be more logical if it was something like:

void f(int i) {
int *p
p = i;
p* = 0;
}

int main(int argc, char* argv[]) {
int a;
f(&a);
return 0;
}

?



Nov 14 '05 #5
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> writes:
Richard Hengeveld wrote:


I'm trying to understand how pointers for function parameters work.
As I understand it, if you got a function like:

void f(int* p) {
*p = 0;
}

int main(int argc, char* argv[]) {
int a;
f(&a);
return 0;
}

It does what you want (namely altering the value of a).
I find this illogical. As far as I can understand,
the address of "a" is passed,
and "*p" is set with this address not "p"
as it should be in my understanding.


Damn it, Tisdale, that's not what he wrote. Here's what Richard
Hengeveld *actually* wrote in the article to which you replied:

] I'm trying to understand how pointers for function parameters work. As I
] understand it, if you got a function like:
]
] void f(int *i)
] {
] *i = 0;
] }
]
] int main()
] {
] int a;
] f(&a);
] return 0;
] }
]
] It does what you want (namely altering the value of a).
] I find this illogical. As far as I can understand, the address of "a" is
] passed, and "*i" is set with this address not "i", as it should be in my
] understanding.

By prefixing the material with "> ", you're telling us that you're
quoting what the previous poster wrote; by preceding it with "Richard
Hengeveld wrote:", you're saying so explicitly. In fact, you're
showing us your version of what you think he should have written.
You've quietly changed the layout of his code (I like his better),
changed the name of the parameter from "i" to "p", and added
gratuitous argc and argv parameters to main.

Now if you had presented your modified version as an improvement of
Richard Hengeveld's code (which is what I did in my response), that
would have been ok. If you had mentioned that you were paraphrasing
what he posted rather than quoting it exactly, that would have been
acceptable as well. You could even have told us why you think your
modified version is an improvement. (In some ways it is, but that's
beside the point.)

You've done this before, and you've been called on it. I have no
realistic expectation that you're going to change your ways this time
either. I'm posting this mostly as a warning to other readers.

If E. Robert Tisdale claims that someone else has written something in
a previous article, don't believe it unless you've verified it by
reading the actual article that he claims to be quoting. Trust him at
your own risk.

--
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.
Nov 14 '05 #6
Richard Hengeveld wrote:

Wouldn't it be more logical if it was something like:

void f(int i) {
int *p
p = i;
p* = 0;

How would it be more logical to assign an integer to a
pointer-to-integer? What problem are you trying to solve?


Brian Rodenborn
Nov 14 '05 #7

"Default User" <fi********@boeing.com.invalid> wrote in message
news:I4********@news.boeing.com...
Richard Hengeveld wrote:

Wouldn't it be more logical if it was something like:

void f(int i) {
int *p
p = i;
p* = 0;

How would it be more logical to assign an integer to a
pointer-to-integer? What problem are you trying to solve?


I'm not trying to solve a problem. I'm just trying to understand C.
In a function without pointer arguments, the argument(s) of that function
are set by value passing:

f(int i)
{
printf("%d", i);
}

int main()
{
int i;
f(i);
return 0;
}

I just don't understand why this is (a little bit) different with pointer
arguments.
Nov 14 '05 #8
Richard Hengeveld wrote:
I understand you set a pointer (if you're not passing to functions) by:

int a, *p;
p = &a;

and not:

p* = &a

Wouldn't it be more logical if it was something like:

void f(int i) {
int *p
p = i;
p* = 0;
}

int main(int argc, char* argv[]) {
int a;
f(&a);
return 0;
}

?


I don't know.
I don't know why K&R chose these semantics
and not the semantics that you suggest.
suppose that you wanted to define a second pointer
to the same object. Would you write

int *p, *q;
p = i;
q = i;

And would you expect (p == q) to be true?
Nov 14 '05 #9
"Richard Hengeveld" <ri**************@hotmail.com> writes:
[...]
Thanks for replying.
Yes, that is exactly what is confusing me.
I understand you set a pointer (if you're not passing to functions) by:

int a, *p;
p = &a;
Right, this sets p to contain the address of a (or, equivalently,
causes p to point to a).
and not:

p* = &a
The unary '*' operator is prefix, not postfix. You could argue that
it would be easier if it were postfix, but that's not how the language
defines it.

If you meant
*p = &a;
that wouldn't make sense. Since p is a pointer to int, *p is an int,
but &a (address of a) is a pointer to int. The types don't match.

In an assignment, the left hand side has to be an expression (e.g., a
name) that refers to an object of some type, and the right hand side
has to be an expression of that same type (not necessarily an object).
(That's not quite true (there are implicit conversions in some cases),
but it's a good enough first approximation.)

So given:
int a;
int *p;
we can have
a = 42; /* the name "a" refers to an object of type int,
"42" is an expression of type int */
p = &a; /* the name "p" refers to an object of type pointer-to-int,
"&a" is an expression of type pointer-to-int */
*p = 2+2; /* the name "*p" refers to an object of type int
(the object happens to be "a"), and "2+2" is an expression
of type int */
Wouldn't it be more logical if it was something like:

void f(int i) {
int *p
p = i;
No, p refers to an object of type pointer-to-int, but i is an expression
of type int. The types don't match. You can legally say "p = &i;".
p* = 0;
p* is a syntax error. *p = 0; is legal, since *p refers to an object
of type int (assuming p has been initialized properly), and 0 is an
expression of type int.
}

int main(int argc, char* argv[]) {
int a;
f(&a);
The function f() expects an argument of type int; you're giving it an
argument of type pointer-to-int. Function argument types have to
match, just as the types in an assignment have to match.
return 0;
}


If you want the function f() to be able to modify an int object that
you pass to it, you have to pass the object's address, and f() has to
take an argument of type pointer-to-int. If f() takes an argument of
type int, it just gets a copy of the value of whatever you pass to it;
f() can do whatever it likes with its own copy, but that won't affect
the original object.

If f() is defined as:

void f(int i) { ... whatever ... }

then this:

int x;
f(x);

can't change the value of x, any more than this:

f(42);

can change the value of 42.

Some languages do have ways of specifying that an argument is passed
in a way that allows the function to modify the original object
(Pascal has VAR parameters, Ada as "in out" and "out" parameters, C++
has reference parameters). C doesn't have such a mechanism.

If you want to argue that C could be improved, there are several
things I can say in response:

1. You're right. C's declaration syntax in particular causes no end
of headaches, especially to novices.

2. It's not going to change. Any significant change would break
existing code. That's just not going to happen. If you want a
language with better syntax than C (and that's a subjective
judgement), you'll just have to use a language other than C.

3. If you're interested in C, you should probably learn the language
as it is before you start worrying about how it could be better. K&R2
(Kernighan & Ritchie's _The C Programming Language_, Second Edition)
is one of the best tutorials; buy or borrow a copy and read it.

--
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.
Nov 14 '05 #10
Richard Hengeveld wrote:

"Default User" <fi********@boeing.com.invalid> wrote in message
news:I4********@news.boeing.com...
Richard Hengeveld wrote:

Wouldn't it be more logical if it was something like:

void f(int i) {
int *p
p = i;
p* = 0;

How would it be more logical to assign an integer to a
pointer-to-integer? What problem are you trying to solve?


I'm not trying to solve a problem. I'm just trying to understand C.
In a function without pointer arguments, the argument(s) of that
function are set by value passing:

f(int i)
{
printf("%d", i);
}

int main()
{
int i;
f(i);
return 0;
}

I just don't understand why this is (a little bit) different with
pointer arguments.


It's not different. What makes you think it is? In both cases,
something is passed by value (that means a copy of it was made) and
assigned to a local variable, the parameter.

It just so happens that in one case it was a integer, and the other it
was a pointer-to-integer. In the second case, a copy of the address was
made and passed to the function. It's still the same address that was
created through the use of the & operator in main().

You don't appear to understand how pointers work. This is fundamental
to the use of the C language. Get a good book and read it. Otherwise,
you are wasting your time and ours.


Brian Rodenborn
Nov 14 '05 #11
Richard Hengeveld wrote:
As far as I can understand, the address of "a" is
passed, and "*i" is set with this address not "i",
as it should be in my understanding.


After
int *i = &a
you have
i == &a
not
*i == &a

--
pete
Nov 14 '05 #12
Richard Hengeveld wrote:

"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message
news:cj**********@nntp1.jpl.nasa.gov...

Probably what is confusing you is the *formal* argument

int* p


Thanks for replying.
Yes, that is exactly what is confusing me.

[newbie answer -- maybe this helps]
int i, *p; // declare an int and a pointer to int
void f(int *p); // declare a function taking a pointer to int parameter

I think you'd understand that function better if you'd write it as

void g(int* p); // make 'int*' stand out

typedef int *pointer_to_int;
typedef int* pointer_to_int;

These two typedefs are absolutely equal. Which one do you prefer?

void h(pointer_to_int p);

--
USENET would be a better place if everybody read: | to email me: use |
http://www.catb.org/~esr/faqs/smart-questions.html | my name in "To:" |
http://www.netmeister.org/news/learn2quote2.html | header, textonly |
http://www.expita.com/nomime.html | no attachments. |
Nov 14 '05 #13
Keith Thompson wrote:
.... snip ...
Incidentally, "i" is a poor name for the parameter. "i" is
commonly used as a name for an int variable; the parameter is a
pointer to int. It's perfectly legal, but potentially confusing.

In the assignment

*i = 0;

"i" is a pointer, and "*i" is an int object. You're assigning the
value 0 to an int object. Which int object? The one i points to,
which happens to be "a".

If you had written

i = 0;

you'd be assigning a value to "i", which is a pointer object; the
value being assigned would be a null pointer.

It might be clearer if you change the names:

void f(int *ptr_param)
{
*ptr_param = 0;
}

int main(void)
{
int int_object;
f(&int_object);
return 0;
}

(In a real program, of course, variables should generally have names
that reflect what they're used for; for this toy example, it's more
important to show their types.)


While I abhor Hungarian notation, I do like to append either p or
ptr to the names of pointer variables.

--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

Nov 14 '05 #14
Keith Thompson wrote:
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> writes:
.... snip mangled quote ...
Damn it, Tisdale, that's not what he wrote. Here's what Richard
Hengeveld *actually* wrote in the article to which you replied:
.... snip details ...
You've done this before, and you've been called on it. I have no
realistic expectation that you're going to change your ways this
time either. I'm posting this mostly as a warning to other readers.

If E. Robert Tisdale claims that someone else has written something
in a previous article, don't believe it unless you've verified it
by reading the actual article that he claims to be quoting. Trust
him at your own risk.


And just when I thought Trollsdale was showing signs of
reformation. He seems to be a dedicated recidivist. Can we apply
the 'three strikes' law somehow?

--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

Nov 14 '05 #15
On Wed, 29 Sep 2004 23:09:10 +0200, "Richard Hengeveld"
<ri**************@hotmail.com> wrote:
Probably what is confusing you is the *formal* argument

int* p
Thanks for replying.
Yes, that is exactly what is confusing me.
I understand you set a pointer (if you're not passing to functions) by:

int a, *p;
p = &a;

and not:

p* = &a

Wouldn't it be more logical if it was something like:

void f(int i) {
int *p
p = i;


I assume you meant p=&i here.
p* = 0;
I assume you meant *p=0 here. This will set i to 0 but I is local to
f. When you return, i ceases to exist. Consequently, the argument in
the calling function is never updated and defeats the purpose.
}

int main(int argc, char* argv[]) {
int a;
f(&a);
With f as defined above, this obviously causes a diagnostic since f is
expecting an int but you are passing an int*.

Going back to your original post which defined f as expecting an int*,
when you call f with this argument, three significant things happen:

i is created as an automatic variable local to f.
i is initialized with the address of a (which is a local variable
local to main.
Control is transferred to f.

Look back at your code at the top of this post and notice how similar
the first two are to what you wrote when not calling a function.
return 0;
}


The concepts to understand are

In a definition, *i defines i as a pointer.

After the definition, i refers to the pointer itself and not the
object being pointed to, if any.

Once the pointer has been initialized, coding *i dereferences the
pointer and evaluates to the object being pointed to.

A function call causes all the parameters of the function to be
initialized with the corresponding arguments used in the calling
statement. (So f(&a) has a very similar effect to p=&a.)
<<Remove the del for email>>
Nov 14 '05 #16
On Thu, 30 Sep 2004 04:13:38 GMT
CBFalconer <cb********@yahoo.com> wrote:
Keith Thompson wrote:
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> writes:
<snip>
If E. Robert Tisdale claims that someone else has written something
in a previous article, don't believe it unless you've verified it
by reading the actual article that he claims to be quoting. Trust
him at your own risk.


And just when I thought Trollsdale was showing signs of
reformation. He seems to be a dedicated recidivist. Can we apply
the 'three strikes' law somehow?


You mean if any of us meet him we get to strike him three times? :-)
--
Flash Gordon
Sometimes I think shooting would be far too good for some people.
Although my email address says spam, it is real and I read it.
Nov 14 '05 #17
"Richard Hengeveld" <ri**************@hotmail.com> wrote in
news:41***********************@news.wanadoo.nl:
How would it be more logical to assign an integer to a
pointer-to-integer? What problem are you trying to solve?
I'm not trying to solve a problem. I'm just trying to understand C.
In a function without pointer arguments, the argument(s) of that
function are set by value passing:


Correct. In this case the called function gets a "copy" of the value to
play with and the caller can be sure that the callee won't modify the
original value in 'i'. This is nice when you want to preserve your value
but have some function create a new value based on your value, e.g.

#include <stdio.h>

static int plusTwo(int copyOfVal)
{
/* Modify copy by adding two to demonstrate
** that the caller's 'val' is not modified.
*/
copyOfVal += 2;

return copyOfVal;
}

static int timesTenModify(int *pVal)
{
int failure = 0;

if (pVal) *pVal *= 10;
else failure = !0;

return failure;
}

int main(void)
{
int failure;
int val = 10;
int valPlusTwo = plusTwo(val);

/* As the caller, I retain my original value of 'val'
** whilst having a worker function calculate 'val' + 2
** for me which I store in 'valPlusTwo'. In this situation
** I do not wish my 'val' to be modified.
*/
printf("My val is %d, and +2 is %d\n", val, valPlusTwo);

/* In this case, I wish to modify 'val' and do not need
** to retain its original value of 10 so I call
** timesTenModify() with a pointer to my 'val' object
** so it can modify 'val' directly.
*/
failure = timesTenModify(&val);
if (failure) printf("Trouble with timesTenModify() call\n");
else printf("My val is now %d\n", val);

return 0;
}
I just don't understand why this is (a little bit) different with
pointer arguments.


Hopefully this simple example will help.

--
- Mark ->
--
Nov 14 '05 #18
CBFalconer <cb********@yahoo.com> spoke thus:
And just when I thought Trollsdale was showing signs of
reformation. He seems to be a dedicated recidivist. Can we apply
the 'three strikes' law somehow?


Perhaps there could be a section of the FAQ dedicated to identifying
posters to plonk?

--
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.
Nov 14 '05 #19
Pedro Graca <he****@hotpop.com> spoke thus:
void g(int* p); // make 'int*' stand out
That's actually misleading - it makes "int*" appear to be a type,
which it is not.
typedef int *pointer_to_int;
typedef int* pointer_to_int; These two typedefs are absolutely equal. Which one do you prefer?


Neither, for real code.

--
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.
Nov 14 '05 #20
"Richard Hengeveld" <ri**************@hotmail.com> wrote in message news:<41***********************@news.wanadoo.nl>.. .
Hi all,

I'm trying to understand how pointers for function parameters work. As I
understand it, if you got a function like:

void f(int *i)
{
*i = 0;
}

int main()
{
int a;
f(&a);
return 0;
}

It does what you want (namely altering the value of a).
I find this illogical. As far as I can understand, the address of "a" is
passed, and "*i" is set with this address not "i", as it should be in my
understanding.
What am I missing?
I think you're getting hung up with declarator syntax as much as
anything else, and that you're looking at the formal parameter
declaration as an actual dereference operation, which is why you're
confused.

C declaration statements follow a "declaration mimics use" paradigm.
When you dereference the pointer to get the value it's pointing to,
you use the expression "*i". The idea is that the declaration of "i"
(a pointer) should closely mirror how it's actually used in the code;
therefore, the declaration looks like this:

int *i

The int-ness of i is specified in the type specifier "int"; the
pointer-ness of i is specified in the declarator "*i". This statement
introduces the symbol "i" as having type pointer-to-int (although the
declaration reads as pointer-to-type-int).

When you pass your value (&a, type pointer-to-int) to this function,
it is written to the formal parameter "i" (type pointer-to-int), *not*
to the expression "*i" (type int).

Hope that helps.
TIA

P.S.
I've really searched for this in the groups faq and elsewhere before I
posted.

Nov 14 '05 #21
Christopher Benson-Manica wrote:
CBFalconer <cb********@yahoo.com> spoke thus:
And just when I thought Trollsdale was showing signs of
reformation. He seems to be a dedicated recidivist. Can we
apply the 'three strikes' law somehow?


Perhaps there could be a section of the FAQ dedicated to
identifying posters to plonk?


Too dynamic. The best I can do is publish my own c.l.c plonk
list. Trollsdale isn't on it because he requires watching else
his alteration tricks will go unnoticed. The FAQ plonks (Answers,
FAQ list) are because I have a copy and don't need any more, and
they are big.

c:\netscape\users\cbf\news\host-netnews.att.net>grep condition=
comp.lang.c.dat
condition=" OR (subject,contains,comp.lang.c Answers)"
condition=" OR (subject,contains,My china ex. girlfriend)"
condition=" OR (from,contains,Kenny McCormack)"
condition=" OR (subject,contains,comp.lang.c FAQ list)"
condition=" OR (from,contains,RoSsIaCrIiLoIA)"
condition=" OR (from,contains,lxrocks)"
condition=" OR (from,contains,Generic Usenet Account)"
condition=" OR (from,contains,SM Ryan)"
condition=" OR (from,contains,Skybuck Flying)"
condition=" OR (subject,contains,C++ wins over C)"
condition=" OR (subject,contains,What is an object)"

--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Nov 14 '05 #22
"Richard Hengeveld" <ri**************@hotmail.com> wrote in message
news:41***********************@news.wanadoo.nl...
Thanks for replying.
Yes, that is exactly what is confusing me.
I understand you set a pointer (if you're not passing to functions) by:

int a, *p;
p = &a;

and not:

p* = &a


This is a syntax error; I assume you meant:

*p = &a;

This is a type mismatch; you're trying to assign an address (a) to an
integer (*p) without a cast. Now, if you did:

p = &a;

This is correct. Then you can do:

*p = 1;

And then you will find that a==1. This is no different than doing:

*(&a) = 1;

S

--
Stephen Sprunk "God does not play dice." --Albert Einstein
CCIE #3723 "God is an inveterate gambler, and He throws the
K5SSS dice at every possible opportunity." --Stephen Hawking

Nov 14 '05 #23
Thanks all for helping me out and being patiant with me.
To be clear, I was not trying to attack c logics or concepts. I was just
trying to learn c. Thanks again.
Richard
Nov 14 '05 #24
Thanks all for helping me out and being patiant with me.
To be clear, I was not trying to attack C logics or concepts. Just trying to
learn C. Thanks again
Nov 14 '05 #25
"CBFalconer" <cb********@yahoo.com> wrote in message
news:41***************@yahoo.com...
Keith Thompson wrote:
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> writes:

... snip mangled quote ...

Damn it, Tisdale, that's not what he wrote. Here's what Richard
Hengeveld *actually* wrote in the article to which you replied:

... snip details ...

You've done this before, and you've been called on it. I have no
realistic expectation that you're going to change your ways this
time either. I'm posting this mostly as a warning to other readers.

If E. Robert Tisdale claims that someone else has written something
in a previous article, don't believe it unless you've verified it
by reading the actual article that he claims to be quoting. Trust
him at your own risk.


And just when I thought Trollsdale was showing signs of
reformation. He seems to be a dedicated recidivist. Can we apply
the 'three strikes' law somehow?

Shut up! It was the same function with a variable changed.

Where's your input? What is your content?

Nothing!

Fuck off!

--
Mabden
Nov 14 '05 #26
"Flash Gordon" <sp**@flash-gordon.me.uk> wrote in message
news:7c************@brenda.flash-gordon.me.uk...
On Thu, 30 Sep 2004 04:13:38 GMT
CBFalconer <cb********@yahoo.com> wrote:
Keith Thompson wrote:
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> writes:
<snip>
If E. Robert Tisdale claims that someone else has written something in a previous article, don't believe it unless you've verified it
by reading the actual article that he claims to be quoting. Trust
him at your own risk.


And just when I thought Trollsdale was showing signs of
reformation. He seems to be a dedicated recidivist. Can we apply
the 'three strikes' law somehow?


You mean if any of us meet him we get to strike him three times? :-)


Shut up!
Nov 14 '05 #27
"Mabden" <mabden@sbc_global.net> writes:
"CBFalconer" <cb********@yahoo.com> wrote in message
news:41***************@yahoo.com...
Keith Thompson wrote:
> "E. Robert Tisdale" <E.**************@jpl.nasa.gov> writes:
>

... snip mangled quote ...
>
> Damn it, Tisdale, that's not what he wrote. Here's what Richard
> Hengeveld *actually* wrote in the article to which you replied:
>

... snip details ...
>
> You've done this before, and you've been called on it. I have no
> realistic expectation that you're going to change your ways this
> time either. I'm posting this mostly as a warning to other readers.
>
> If E. Robert Tisdale claims that someone else has written something
> in a previous article, don't believe it unless you've verified it
> by reading the actual article that he claims to be quoting. Trust
> him at your own risk.


And just when I thought Trollsdale was showing signs of
reformation. He seems to be a dedicated recidivist. Can we apply
the 'three strikes' law somehow?

Shut up! It was the same function with a variable changed.

Where's your input? What is your content?

Nothing!

Fuck off!


Mabden, whoever you are, I am sick and tired of your insults. You've
sometimes shown signs of being worth talking to, but if I had a
killfile, you would have been in it several times over by now.
Tisdale deliberately forged a quotation, making it appear that the
previous poster had written something he didn't. He changed the
formatting of the OP's code (the original was better). He changed a
variable name; the new name was clearer, but he didn't bother to say
that. This is unacceptable behavior, and I don't choose to sit
quietly by and let other readers be lied to.

If you don't like our replies, feel free to ignore them. Killfile us
if that makes you happy.

As for your obscene language, it doesn't particularly bother me,
especially if it's used creatively (though I try to avoid it in public
forums); you're just not very good at it.

--
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.
Nov 14 '05 #28
Mabden wrote:
.... snip ...
Where's your input? What is your content?

Nothing!

Fuck off!


PLONK

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 14 '05 #29
"Keith Thompson" <ks***@mib.org> wrote in message
news:ln************@nuthaus.mib.org...
"Mabden" <mabden@sbc_global.net> writes:
"CBFalconer" <cb********@yahoo.com> wrote in message
news:41***************@yahoo.com...
Keith Thompson wrote:
> "E. Robert Tisdale" <E.**************@jpl.nasa.gov> writes:
>
... snip mangled quote ...
>
> Damn it, Tisdale, that's not what he wrote. Here's what Richard
> Hengeveld *actually* wrote in the article to which you replied:
>
... snip details ...
>
> You've done this before, and you've been called on it. I have no
> realistic expectation that you're going to change your ways this
> time either. I'm posting this mostly as a warning to other readers. >
> If E. Robert Tisdale claims that someone else has written something > in a previous article, don't believe it unless you've verified it
> by reading the actual article that he claims to be quoting. Trust > him at your own risk.

And just when I thought Trollsdale was showing signs of
reformation. He seems to be a dedicated recidivist. Can we apply
the 'three strikes' law somehow?
Shut up! It was the same function with a variable changed.

Where's your input? What is your content?

Nothing!

Fuck off!


Mabden, whoever you are, I am sick and tired of your insults. You've
sometimes shown signs of being worth talking to, but if I had a
killfile, you would have been in it several times over by now.


Well, stop trolling Tisdale unless you post actual content.
Tisdale ....
Get over it.
If you don't like our replies, feel free to ignore them. Killfile us
if that makes you happy.
Ditto.
As for your obscene language, it doesn't particularly bother me,
especially if it's used creatively (though I try to avoid it in public
forums); you're just not very good at it.


Well, I use strong language with my friends (yes, I have some...) and
sometimes forget how some posters don't in their Real Life (tm).

I just have so many newsgroups to get through and a limited timeslice.
To have to read a long post about how this function was changed from "i"
to "p" and then compare them, and then find no difference, and then
realize, "Oh, it's just KT on his period again" gets really old.

Can't you just killfile Tisdale and be done with it, Nanny?

--
Mabden
Nov 14 '05 #30
"Mabden" <mabden@sbc_global.net> wrote:
"Flash Gordon" <sp**@flash-gordon.me.uk> wrote:
CBFalconer <cb********@yahoo.com> wrote:
Keith Thompson wrote:
> If E. Robert Tisdale claims that someone else has written
> something in a previous article, don't believe it unless
> you've verified it by reading the actual article that he
> claims to be quoting. Trust
> him at your own risk.
And just when I thought Trollsdale was showing signs of
reformation. He seems to be a dedicated recidivist. Can we apply
the 'three strikes' law somehow?

You mean if any of us meet him we get to strike him three times? :-)


Shut up!


We seem to have a Trollsdale apologist!
Nov 14 '05 #31
"Old Wolf" <ol*****@inspire.net.nz> wrote in message
news:84*************************@posting.google.co m...
We seem to have a Trollsdale apologist!


Sad, aren't I?

--
Mabden
Nov 14 '05 #32
Old Wolf wrote:
"Mabden" <mabden@sbc_global.net> wrote:
"Flash Gordon" <sp**@flash-gordon.me.uk> wrote:
CBFalconer <cb********@yahoo.com> wrote:
Keith Thompson wrote:

> If E. Robert Tisdale claims that someone else has written
> something in a previous article, don't believe it unless
> you've verified it by reading the actual article that he
> claims to be quoting. Trust
> him at your own risk.

And just when I thought Trollsdale was showing signs of
reformation. He seems to be a dedicated recidivist. Can we apply
the 'three strikes' law somehow?

You mean if any of us meet him we get to strike him three times? :-)


Shut up!


We seem to have a Trollsdale apologist!


Not here any more. I awarded him the Royal Order of the PLONK.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!

Nov 14 '05 #33
"Mabden" <mabden@sbc_global.net> wrote in message news:<NT****************@newssvr13.news.prodigy.co m>...
"CBFalconer" <cb********@yahoo.com> wrote in message
news:41***************@yahoo.com...
Keith Thompson wrote:
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> writes:
... snip mangled quote ...
Damn it, Tisdale, that's not what he wrote. Here's what Richard
Hengeveld *actually* wrote in the article to which you replied:
... snip details ...
You've done this before, and you've been called on it. I have no
realistic expectation that you're going to change your ways this
time either. I'm posting this mostly as a warning to other readers.

If E. Robert Tisdale claims that someone else has written something
in a previous article, don't believe it unless you've verified it
by reading the actual article that he claims to be quoting. Trust
him at your own risk.
And just when I thought Trollsdale was showing signs of
reformation. He seems to be a dedicated recidivist. Can we apply
the 'three strikes' law somehow?

Shut up! It was the same function with a variable changed.


Even so, Tisdale should have marked his changes. It raises red flags
with me because I've dealt with posters in other fora who
*significantly* edit quoted material for patently dishonest purposes
(i.e., change a withering criticism into wholehearted support).

If you edit quoted material *FOR ANY REASON*, even if it's just to
change a stinking variable name, you should mark those edits
*somehow*.

When someone comes along to read the thread after the original article
has fallen off the server, what they'll be reading is Tisdale's
unmarked edit of the original, and if that reader has problems with
Tisdale's style or corrections, they'll erroneously attribute those
problems to the OP. That doesn't help the OP much.
Where's your input? What is your content?

Nothing!

Fuck off!


Where's *your* input? What is *your* content?
Nov 14 '05 #34
"John Bode" <jo*******@my-deja.com> wrote in message
news:43**************************@posting.google.c om...
"Mabden" <mabden@sbc_global.net> wrote in message

news:<NT****************@newssvr13.news.prodigy.co m>...
"CBFalconer" <cb********@yahoo.com> wrote in message
news:41***************@yahoo.com...
Keith Thompson wrote:
> "E. Robert Tisdale" <E.**************@jpl.nasa.gov> writes:
>

... snip mangled quote ...
>
> Damn it, Tisdale, that's not what he wrote. Here's what Richard
> Hengeveld *actually* wrote in the article to which you replied:
>

... snip details ...
>
> You've done this before, and you've been called on it. I have no > realistic expectation that you're going to change your ways this
> time either. I'm posting this mostly as a warning to other readers. >
> If E. Robert Tisdale claims that someone else has written something > in a previous article, don't believe it unless you've verified it > by reading the actual article that he claims to be quoting. Trust > him at your own risk.

And just when I thought Trollsdale was showing signs of
reformation. He seems to be a dedicated recidivist. Can we apply
the 'three strikes' law somehow?

Shut up! It was the same function with a variable changed.


Even so, Tisdale should have marked his changes. It raises red flags
with me because I've dealt with posters in other fora who
*significantly* edit quoted material for patently dishonest purposes
(i.e., change a withering criticism into wholehearted support).

If you edit quoted material *FOR ANY REASON*, even if it's just to
change a stinking variable name, you should mark those edits
*somehow*.

When someone comes along to read the thread after the original article
has fallen off the server, what they'll be reading is Tisdale's
unmarked edit of the original, and if that reader has problems with
Tisdale's style or corrections, they'll erroneously attribute those
problems to the OP. That doesn't help the OP much.
Where's your input? What is your content?

Nothing!

Fuck off!


Where's *your* input? What is *your* content?


Too subtle for you? I can be that way, as I wouldn't wish to offend.

I was saying that a no content post wastes my time, and that I'm a Big
Boy and can distinguish a good post from a bad post all on my own. I
don't need someone following along to say, "Hey, that last post you read
might not be fully accurate! I don't want you to believe every word of
that last post! Hey, something on the internet may be misrepresenting
itself as fact, when in fact it is fiction! There's this one guy, and
you know, for some reason he changes everything he touches, and DON'T
LISTEN TO HIM!!!!! PLEEEEEZZZZEEEE!!!! --- There, I feel good about
myself because I've warned the world!"

That is what I object to.

--
Mabden
Nov 14 '05 #35
Mabden wrote:

Well, stop trolling Tisdale unless you post actual content.

I thought Mabden was starting to get a clue, but has gone berserk over
the weekend.
*plonk*


Brian Rodenborn
Nov 14 '05 #36
CBFalconer <cb********@yahoo.com> wrote:
Old Wolf wrote:
"Mabden" <mabden@sbc_global.net> wrote:
Shut up!


We seem to have a Trollsdale apologist!


Not here any more. I awarded him the Royal Order of the PLONK.


So you've given him a ROP to hang himself? :-)
Nov 14 '05 #37
"Old Wolf" <ol*****@inspire.net.nz> wrote in message
news:84*************************@posting.google.co m...
CBFalconer <cb********@yahoo.com> wrote:
Old Wolf wrote:
"Mabden" <mabden@sbc_global.net> wrote:

> Shut up!

We seem to have a Trollsdale apologist!


Not here any more. I awarded him the Royal Order of the PLONK.


So you've given him a ROP to hang himself? :-)


My butt still hurts...

--
Mabden
Nov 14 '05 #38
"Default User" <fi********@boeing.com.invalid> wrote in message
news:I5*******@news.boeing.com...
Mabden wrote:

Well, stop trolling Tisdale unless you post actual content.

I thought Mabden was starting to get a clue, but has gone berserk over
the weekend.


OK, I do tend to do that. My bad.

*plonk*

Why not just plonk Tisdale? Then you won't complain about minutia (sp?)
and I won't feel it necessary to respond what a bunch a whinging
bastards you all are...

--
Mabden
Nov 14 '05 #39
On Tue, 05 Oct 2004 08:47:23 GMT
"Mabden" <mabden@sbc_global.net> wrote:

<snip>
Why not just plonk Tisdale? Then you won't complain about minutia
(sp?) and I won't feel it necessary to respond what a bunch a whinging
bastards you all are...


Tisdale doesn't get plonked by a lot of people because if no one pointed
out his errors people who did not know any better might believe him and
have problems as a result.

So people who are gratuitously insulting but either provide no advice or
correct advice get plonked, people who provide incorrect advice
generally don't get plonked even if they are gratuitously rude.
--
Flash Gordon
Sometimes I think shooting would be far too good for some people.
Although my email address says spam, it is real and I read it.
Nov 14 '05 #40
"Mabden" <mabden@sbc_global.net> wrote:
"Default User" <fi********@boeing.com.invalid> wrote in message
news:I5*******@news.boeing.com...
*plonk*
Why not just plonk Tisdale? Then you won't complain about minutia (sp?)


Because changing someone's post behind his back is _not_ a minutium. It
is a serious matter...
and I won't feel it necessary to demonstrate what a whinging
bastard I am...


....if you see what I mean.

Richard
Nov 14 '05 #41

Richard Bos wrote:
"Mabden" <mabden@sbc_global.net> wrote:
"Default User" <fi********@boeing.com.invalid> wrote in message
news:I5*******@news.boeing.com...
*plonk*


Why not just plonk Tisdale? Then you won't complain about minutia (sp?)


Because changing someone's post behind his back is _not_ a minutium. It
is a serious matter...
and I won't feel it necessary to demonstrate what a whinging
bastard I am...


...if you see what I mean.


Oh no, must I now plonk you, Richard, for not saying it clearly... ;-)

Nice one, btw
--Michael

Nov 14 '05 #42

"Flash Gordon" <sp**@flash-gordon.me.uk> wrote in message
news:nr************@brenda.flash-gordon.me.uk...
On Tue, 05 Oct 2004 08:47:23 GMT
"Mabden" <mabden@sbc_global.net> wrote:

<snip>
Why not just plonk Tisdale? Then you won't complain about minutia
(sp?) and I won't feel it necessary to respond what a bunch a whinging bastards you all are...
Tisdale doesn't get plonked by a lot of people because if no one

pointed out his errors people who did not know any better might believe him and have problems as a result.
It's called "the internet" not "the gospel".

So people who are gratuitously insulting but either provide no advice or correct advice get plonked, people who provide incorrect advice
generally don't get plonked even if they are gratuitously rude.

Well, it's nice to know that correct advice is plonkable. I'll try to
steer clear of providing any of that. So, in your world, do people say
"Goodbye" when you meet them and "Hello" when you depart?

Anyhow, I was just annoyed (again) at the bandwidth waste, and lack of
sleep (ok, too much beer) made me think it was important to comment.
Forget it and let's let this thread die.

--
Mabden
Nov 14 '05 #43
"Mabden" <mabden@sbc_global.net> writes:
"Flash Gordon" <sp**@flash-gordon.me.uk> wrote in message
news:nr************@brenda.flash-gordon.me.uk... [...]
So people who are gratuitously insulting but either provide no
advice or correct advice get plonked, people who provide incorrect
advice generally don't get plonked even if they are gratuitously
rude.


Well, it's nice to know that correct advice is plonkable. I'll try to
steer clear of providing any of that. So, in your world, do people say
"Goodbye" when you meet them and "Hello" when you depart?


The point is that we need to keep an eye on posters who post incorrect
advice, so newbies aren't misled. A lot of people would like to plonk
ERT, for example, but continue to read his articles so they can
correct his misstatements. Someone who is insufferably rude but
either offers correct advice or doesn't offer advice at all can be
safely ignored, since he's not likely to mislead anyone. It's how the
newsgroup defends itself.
Anyhow, I was just annoyed (again) at the bandwidth waste, and lack of
sleep (ok, too much beer) made me think it was important to comment.
Forget it and let's let this thread die.


Do us all a favor and don't post when you're drunk or hung over. This
isn't just a conversation that everybody is going to forget; everthing
you post here is archived permanently. The impression you've given so
far is not a good one.

--
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.
Nov 14 '05 #44
"Keith Thompson" <ks***@mib.org> wrote in message
news:ln************@nuthaus.mib.org...
"Mabden" <mabden@sbc_global.net> writes:
"Flash Gordon" <sp**@flash-gordon.me.uk> wrote in message
news:nr************@brenda.flash-gordon.me.uk...

[...]
So people who are gratuitously insulting but either provide no
advice or correct advice get plonked, people who provide incorrect
advice generally don't get plonked even if they are gratuitously
rude.


Well, it's nice to know that correct advice is plonkable. I'll try to steer clear of providing any of that. So, in your world, do people say "Goodbye" when you meet them and "Hello" when you depart?


The point is that we need to keep an eye on posters who post incorrect
advice, so newbies aren't misled. A lot of people would like to plonk
ERT, for example, but continue to read his articles so they can
correct his misstatements. Someone who is insufferably rude but
either offers correct advice or doesn't offer advice at all can be
safely ignored, since he's not likely to mislead anyone. It's how the
newsgroup defends itself.
Anyhow, I was just annoyed (again) at the bandwidth waste, and lack of sleep (ok, too much beer) made me think it was important to comment.
Forget it and let's let this thread die.


Do us all a favor and don't post when you're drunk or hung over. This
isn't just a conversation that everybody is going to forget; everthing
you post here is archived permanently. The impression you've given so
far is not a good one.


You've never Googled "Mabden" have you?! (I don't mean my posts)

--
Mabden
Nov 14 '05 #45
"Mabden" <mabden@sbc_global.net> writes:
"Keith Thompson" <ks***@mib.org> wrote in message
news:ln************@nuthaus.mib.org...
"Mabden" <mabden@sbc_global.net> writes: [...]
> Anyhow, I was just annoyed (again) at the bandwidth waste, and
> lack of sleep (ok, too much beer) made me think it was important
> to comment. Forget it and let's let this thread die.


Do us all a favor and don't post when you're drunk or hung over. This
isn't just a conversation that everybody is going to forget; everthing
you post here is archived permanently. The impression you've given so
far is not a good one.


You've never Googled "Mabden" have you?! (I don't mean my posts)


No, I hadn't. Now I have. It appears to be a reference to the
fantasy works of Michael Moorcock. I'd ask you what the point is if I
cared.

I'll post to this thread again only if there's a technical C issue to
be discussed.

--
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.
Nov 14 '05 #46
On Tue, 05 Oct 2004 20:46:59 GMT, in comp.lang.c , "Mabden"
<mabden@sbc_global.net> wrote:
You've never Googled "Mabden" have you?! (I don't mean my posts)


Why would anyone care about you fantasising about being a Moorcock
character? This is clc, not alt.weird.fantasy.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 14 '05 #47
"Keith Thompson" <ks***@mib.org> wrote in message
news:ln************@nuthaus.mib.org...
"Mabden" <mabden@sbc_global.net> writes:
"Keith Thompson" <ks***@mib.org> wrote in message
news:ln************@nuthaus.mib.org...
"Mabden" <mabden@sbc_global.net> writes: [...] > Anyhow, I was just annoyed (again) at the bandwidth waste, and
> lack of sleep (ok, too much beer) made me think it was important
> to comment. Forget it and let's let this thread die.

Do us all a favor and don't post when you're drunk or hung over. This isn't just a conversation that everybody is going to forget; everthing you post here is archived permanently. The impression you've given so far is not a good one.
You've never Googled "Mabden" have you?! (I don't mean my posts)


No, I hadn't. Now I have. It appears to be a reference to the
fantasy works of Michael Moorcock. I'd ask you what the point is if I
cared.


Not just Moorcock, it's used elsewhere. It is generally a crude,
actively cruel, and mischievous race or spirit. The point (not that you
asked or cared) is that you are complaining about my "behaviour", but my
signature should be a hint that I'm not entirely housebroken.

But, I'm not hopeless. I just tend to slip back a step for every two
steps forward...
I'll post to this thread again only if there's a technical C issue to
be discussed.


Well, I tried to halt the thread once already...

--
Mabden
Nov 14 '05 #48
On Wed, 06 Oct 2004 00:35:49 GMT, in comp.lang.c , "Mabden"
<mabden@sbc_global.net> wrote:
Not just Moorcock, it's used elsewhere. It is generally a crude,
actively cruel, and mischievous race or spirit. The point (not that you
asked or cared) is that you are complaining about my "behaviour", but my
signature should be a hint that I'm not entirely housebroken.
Actually, what it shows is that you're extremely childish if you think that
naming yourself after a fantasy creature that you like to imagine yourself
being is even remotely relevant in a technical group.

I'll post to this thread again only if there's a technical C issue to
be discussed.


Just stick to C.
Well, I tried to halt the thread once already...


I'm not aware that you own usenet. If you want to stop a thread, then
you're being hitlerian and fascist.*

* that comment may go over your head tho.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
Nov 14 '05 #49
Richard Hengeveld wrote:

I'm not trying to solve a problem. I'm just trying to understand C.
In a function without pointer arguments, the argument(s) of that function
are set by value passing:

f(int i)
{
printf("%d", i);
}

int main()
{
int i;
f(i);
return 0;
}

I just don't understand why this is (a little bit) different with pointer
arguments.


It's not different at all really.

Grab:
1. A piece of paper.
2. A pen.
3. A house on a street.

The piece of paper is now your pointer variable, (int *p for example).
The pen is your assignment operator.
The house is your int object (int house for example).

But aside from that, if you want to tell anyone how to get to your house
do you pass them the whole house? I wouldn't think so (but you never
know). So what do you do? You write it down on a piece of paper. No, you
do not write down the house, you write down the address of the house.
Now your friends can come over after you give them that piece of paper.
Can they do anything to your house, like enter it, set it on fire just
by having your piece of paper? No they can't, they have to go to your
house first.

So essentially, the house has (at least) two aspects to it, the house
itself and its address. You have to make it clear which you want. With
variables in C it's the same thing. They have a value and an address.
You have to be clear on which you want. The & operator seems apt in
telling the compiler what it is you require. The piece of paper as well,
you have to be clear on whether you want to change the piece of paper
or the thing that is at the address it holds. In other words, how do you
tell your program to set fire to the piece of paper, how about whatever
is at the address written down? Well you simply say, set fire to this
piece of paper, or in the latter case you say set fire to what resides
at the address written down on this piece of paper.

See, the second statement a bit complex than the first. So should
require some more syntax as well. Also the syntax makes sense when
you consider that pointers are completely normal variables. When you
want something else than the value stored in a variable then you
need to tell the compiler that.
HTH.
--
Thomas.
Nov 14 '05 #50

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: tuko | last post by:
Hello kind people. I have the classes "point", "curve", "surface", "region" as shown below. Every class has a member function that returns a list of pointers to objects that comprise the *this...
7
by: tuchka | last post by:
Hi, guys! I am very new here and just started to learn C. I have previous java exp. however. I'm abs. stuck on pointers and i'm unable comprehend algorithm of simple program that reverses chars...
12
by: Rob Morris | last post by:
Hi, I'm teaching myself C for fun. I wrote the litle program listed below to convert rot13 text. It reads one char at a time and converts it via pointers. The constant char* letters holds the...
4
by: Deniz Bahar | last post by:
Hello, A couple days ago my friend (OOP guy) shows me what OOP was all about in C++. This morning I figured I can do pretty much the same thing with C (by putting function pointers in...
4
by: Garry Freemyer | last post by:
I'm trying to convert this macro to a c# function but I have a big problem. It's on the LEFT side of an assignment statement and I am extremely flustered over this one because I'm a little rusty...
3
by: Sam Learner | last post by:
Hello everyone, I am developping an application, I create a thread for the application because it is about to download a large file, and wanted it to do it inside of a thread... Now, the function...
42
by: Martin Jørgensen | last post by:
Hi, I'm trying to move a matlab program into c language. For those who knows matlab, this is the line I want to program in c: hx(1:nx,1:ny) = 0; % nx=10, ny=10 It works on a 2-dimensional...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.