Re: Passing pointers?
I have several introductory C books Brian. None of which show this type of
example, unfortunately!
I am currently finishing up several aspects of my project. And as soon as I
have a chance Brian, I will go out and *carefully* choose a better C book
then the ones I have. I appreciate your concern! :)
Therefore the required parameter in:
y(*a); //Is this correct??? I doubt it!
is a pointer of integer type "int*", which contains an address.
I could be wrong, but I believe this is it???
==============================
void x(int *a)
{
y(a); //"a" contains an address.
}
void y(int *b)
{
int x;
x=*b; //99 should be assigned to x.
}
void main()
{
int z=99;
x(&z);
}
===================================
If you still feel like replying back, let me know!
Thankyou for getting back!
--
Best regards
Robert
"Brian Muth" wrote:
"Robby" <Robby@discussions.microsoft.com> wrote in message news:29A7E439-7BD1-4142-AD5C-DBCD484A0591@microsoft.com...
Hello,
I am wondering when passing a pointer to a function and require to further
pass it to another funtion (two functions deep), can we re-pass the pointer
to the second function using the "*" ?
Basically wrong values are displayed when dereferencing b in y function.
here is an example :
====================================
void x(int *a)
{
y(*a); //Is this correct??? I doubt it!
}
`
"a" is an int*
"*a" is an int
Therefore you are trying to pass an "int" as a parameter. Which is wrong, since the required parameter is "int*".
As an aside, have you bought yourself an introductory book on C as I have suggested?
Brian