f



pointer to a pointer

My situation:

I have a function that takes a pointer to an FSref as an argument. In 
the body of the function is a function call that also takes a pointer to 
an FSRef. I need to pass my original FSRef, but since I have only a 
pointer to it, I am assuming I need to dereference it twice when I call 
the second function. However, using something like &&myFSRef in the 
second function doesn't work.

Can anyone tell me the proper way to do this?

Thanks.
0
Steven
1/15/2005 3:24:57 PM
comp.mac.codewarrior 2568 articles. 0 followers. ja7789 (3) is leader. Post Follow

3 Replies
662 Views

Similar Articles

[PageSpeed] 26

In article <1105802448.cd52b3255e6c95476ce23f7be215a6a3@teranews>,
 Steven Daedelus <sdaedelus@ira.gov> wrote:

> I have a function that takes a pointer to an FSref as an argument. In 
> the body of the function is a function call that also takes a pointer to 
> an FSRef. I need to pass my original FSRef, but since I have only a 
> pointer to it, I am assuming I need to dereference it twice when I call 
> the second function. However, using something like &&myFSRef in the 
> second function doesn't work.

&&myFSRef could never parse, since:
a.) "&&" is a token that would be picked up by the parser to mean 
logical, short-circuiting "and". Note: "and" is a keyword in the C++ 
language that means itself, so I prefer to use it, not "&&".

b.) If the parser DID tokenize it correctly, the compiler would still 
give you an error message, since you are asking for the address of an 
address, but an address is just a number, it has no address any more 
than you can ask for the address of "3". An address is not an "l-value" 
where "l-value" is the term for the kind of value that can appear on the 
left side of an assignment statement. "foo=2;" is legal because foo is 
an l-value. "2=foo;" is not legal because 2 is not an l-value. "&foo" is 
legal, "& & foo" is not.

Your question contains its own answer:

FSRef originalRef;

void Func1(FSRef *fsRefp){

//... does something with it here.

}

void Func2(FSRef *fsRefp){
   Func1(&originalRef); // Note 1 below
   Func1(fsRefp);
}

//         "In the body of the function is a function call"
// Note 1: "that also takes a pointer to an FSRef"

Since it takes what you've already got, you just pass it.

Func2(&originalRef);

-- 
David Phillip Oster
0
David
1/15/2005 3:58:42 PM

David Phillip Oster wrote:
> In article <1105802448.cd52b3255e6c95476ce23f7be215a6a3@teranews>,
>  Steven Daedelus <sdaedelus@ira.gov> wrote:
> 
> 
>>I have a function that takes a pointer to an FSref as an argument. In 
>>the body of the function is a function call that also takes a pointer to 
>>an FSRef. I need to pass my original FSRef, but since I have only a 
>>pointer to it, I am assuming I need to dereference it twice when I call 
>>the second function. However, using something like &&myFSRef in the 
>>second function doesn't work.

Or, if this is what you meant:

void Func1( FSRef* inRef ) {
	Func2( *inRef );
}

void Func2( FSRef ref ) {
	
}


> 

> 
> &&myFSRef could never parse, since:
> a.) "&&" is a token that would be picked up by the parser to mean 
> logical, short-circuiting "and". Note: "and" is a keyword in the C++ 
> language that means itself, so I prefer to use it, not "&&".
> 
> b.) If the parser DID tokenize it correctly, the compiler would still 
> give you an error message, since you are asking for the address of an 
> address, but an address is just a number, it has no address any more 
> than you can ask for the address of "3". An address is not an "l-value" 
> where "l-value" is the term for the kind of value that can appear on the 
> left side of an assignment statement. "foo=2;" is legal because foo is 
> an l-value. "2=foo;" is not legal because 2 is not an l-value. "&foo" is 
> legal, "& & foo" is not.
> 
> Your question contains its own answer:
> 
> FSRef originalRef;
> 
> void Func1(FSRef *fsRefp){
> 
> //... does something with it here.
> 
> }
> 
> void Func2(FSRef *fsRefp){
>    Func1(&originalRef); // Note 1 below
>    Func1(fsRefp);
> }
> 
> //         "In the body of the function is a function call"
> // Note 1: "that also takes a pointer to an FSRef"
> 
> Since it takes what you've already got, you just pass it.
> 
> Func2(&originalRef);
> 
0
Sexy27
1/15/2005 4:23:28 PM
In article 
<oster-BAE656.07583215012005@newssvr21-ext.news.prodigy.com>,
 David Phillip Oster <oster@ieee.org> wrote:

> In article <1105802448.cd52b3255e6c95476ce23f7be215a6a3@teranews>,
>  Steven Daedelus <sdaedelus@ira.gov> wrote:
> 
> > I have a function that takes a pointer to an FSref as an argument. In 
> > the body of the function is a function call that also takes a pointer to 
> > an FSRef. I need to pass my original FSRef, but since I have only a 
> > pointer to it, I am assuming I need to dereference it twice when I call 
> > the second function. However, using something like &&myFSRef in the 
> > second function doesn't work.
> 
> &&myFSRef could never parse, since:
> a.) "&&" is a token that would be picked up by the parser to mean 
> logical, short-circuiting "and". Note: "and" is a keyword in the C++ 
> language that means itself, so I prefer to use it, not "&&".
> 
> b.) If the parser DID tokenize it correctly, the compiler would still 
> give you an error message, since you are asking for the address of an 
> address, but an address is just a number, it has no address any more 
> than you can ask for the address of "3". An address is not an "l-value" 
> where "l-value" is the term for the kind of value that can appear on the 
> left side of an assignment statement. "foo=2;" is legal because foo is 
> an l-value. "2=foo;" is not legal because 2 is not an l-value. "&foo" is 
> legal, "& & foo" is not.
> 
> Your question contains its own answer:
> 
> FSRef originalRef;
> 
> void Func1(FSRef *fsRefp){
> 
> //... does something with it here.
> 
> }
> 
> void Func2(FSRef *fsRefp){
>    Func1(&originalRef); // Note 1 below
>    Func1(fsRefp);
> }
> 
> //         "In the body of the function is a function call"
> // Note 1: "that also takes a pointer to an FSRef"
> 
> Since it takes what you've already got, you just pass it.
> 
> Func2(&originalRef);

Of course.

I think the only thing being short-circuited was my brain.
0
Steven
1/15/2005 6:52:00 PM
Reply:

Similar Artilces:

Pointers, pointers, pointers.......
Hi group. Asking again some help to better understand the basic principles of RPL.... In RPLMAN they say: >>>In the most general definition of RPL, I is an object pointer >>>pointing to a composite object that is the top of a stack of >>>composite objects called the runstream. >>>R points to the rest of the runstream stack. What is really meant by *the rest of the runstream* ? Is R pointing to the object right after the one pointed by I? Is R pointing to the rest of the stack *as a whole* (how's it possible?) Anything else I didn't catch? >>...

pointers, pointers, pointers...
Hi There, I came up with following sample code to demonstrate my issue: #include <18F87K22.h> #device HIGH_INTS=TRUE, adc=16, ICD=TRUE #fuses NOWDT //No Watch Dog Timer #fuses WDT128 //Watch Dog Timer uses 1:128 #fuses HSM //Hi-Speed crystal oscillator #fuses NOBROWNOUT //No brownout reset #fuses NOPLLEN //No PLL enabled #fuses BBSIZ1K //1K words Boot Block size #fuses NOXINST //Extended set extension and Indexed typedef struct{ int8 foo, test; } Th...

Matlab, pointers and pointers to pointers
Matlab stores matrices using simple pointers in order to allocate memory. Using pointers to pointers, according to my experience, we could obtain the following benefits: - code would run faster (I think up to 70%) - memory would be allocated in a better way Why this solution is not used? There are some limitations? Luigi Luigi: <SNIP longing for pointers - not to heaven - to memory... > Why this solution is not used? There are some limitations... <luigi> a fact of life that we all have to live with: it IS just NOT happening... -or- at least it is not happening since 1984... d...

pointer vs pointer to pointer
AIM: To write a queue with 3 operations. WHAT I GOT: It works PROBLEM: Have a question: Why do "pointer to pointer" in enqueue() and "a pointer" to deleteElement() both work fine ? Will enqueue() work fine if I pass just "a pointer" to it ? Will deleteElement() work fine if I pass "pointer to pointer" ? /* A queue implementataion with the operations that I need: * (1) Add element to the front of the queue * (2) remove an element with a unique ID (string constant) * (3) compare 2 elements (string comparison) * (4) print queue * ...

Pointer to pointer or reference to pointer
The way I understand it Reference To pointer as function parameter eg. void RP(int *&rpMem) {} rpMem is actually an alias for the pointer outside the function right? So I would access it exactly with the same syntax just like outside pointer right? e.g. void RP(int &*rpMem) { *rpMem = 125; rpMem++; } int Mem = 123; int *pMem = &Mem; // pMem = for example 5000 *pMem = 124; // Mem = 124; RP(pMem); // Mem = 125, pMem = 5004 Is the above correct? A <a@a.a> wrote: > e.g. > > void RP(int &*rpMem) > { > *rpMem = 125; > rpMem++; &g...

Pointer-to-pointer-to-pointer question
The code example below shows the dynamic allocation of a 2D array. I must admit that it took quite a while for me to get there (I already have another posting to that effect), but I am glad that I finally got it working. Now here's the problem: I am able to get the 2D array dynamically allocated correctly as long as I am doing it "in-line" (i.e. without invoking any function). The moment I try to do it in another function, I get a core dump. Any help will be appreciated. Since this function is expected to update a pointer-to-pointer type, I am actually passing the pointer-...

More on pointers to pointers.
I suspect I'm missing a broader concept here. Okay, given the following code: #include <stdio.h> int main(void) { char *ptr[] = {"Garbage", "test", "work"}; char **arg; arg = ptr; printf("The string is: %s\n", ptr[1]); return 0; } Why am I not allowed to do something like: arg = &ptr; ? I guess even more to the point, why is this legal? arg = &(*ptr) ; Chad Chad said: > I suspect I'm missing a broader concept here. Okay, given the following > code: > > #include <stdio.h> > > in...

pointers to pointers
Hi, i understood what pointers are and all stuff, and now i'm at the part with pointers to pointers and my book doesn't really help on this issue. let be: int a,*p,**q; how to make use of **q,*q and q ? Which who's address and/or who's value contains. I would like some examples like p=&a;// p contains the address of a and *p contains it's value but regarding **q,*q respectively q. Thanks. apropo wrote: > Hi, > i understood what pointers are and all stuff, and now i'm at the part > with pointers to pointers and my book doesn't really help on...

pointer to pointer
Its just a very simple and basic program to learn exactly what is described in comments here. Can you provide a better (and short) exercise ? /* A program to learn how to use a pointer to a pointer. Here we take an array of char pointers. A char* in the array, of course, points * to some char. Array has only one element. We change the value of char pointed by array's element using a function. * * VERSION 0.0 */ #include <stdio.h> void replace_char_value(char* [], char); int main(void) { char* arrc[2] = {0}; char c = 'c'; arrc[0] = &c;...

Pointers pointers.
I thought I could assign an array of chars to a pointer to pointer. However, when I do the following: #include <stdio.h> int main(void) { char buff[] ="test"; char **output = &buff; return 0; } I get: $gcc -g ptr.c -o ptr ptr.c: In function `main': ptr.c:5: warning: initialization from incompatible pointer type What am I doing wrong here? Chad Chad wrote: > I thought I could assign an array of chars to a pointer to pointer. > However, when I do > the following: > > #include <stdio.h> > > int main(void) { > char buf...

pointer of pointer
Hello, I have to make an array which size of the lines depends of the line. I am sure I am not clear so here is an exemple of what I mean : a is an array of n lines each line contain a different number of elements I have tried to implement something like this a=PTRARR(n) FOR i=0,n-1 DO BEGIN a(i)=Ptr_New ENDFOR First I am not sure it is the best way to compute this, second if yes I don't how to implemente the value of the "a(i,j)" element. If somebody can help me... Best regards, Claire Hey Claire, If you absolutely must have each element of "a" be an array...

Pointers for these pointers...?
Hi Everyone: I'm trying to develop a property list to include as metadata about my object classes. i.e. I want each class I'm developing to include a PropertyList which will contain ObjectProperty pointers. ObjectProperty is a class containing the typeid.name() of a type as it's ObjectType as well as an ObjectName and ObjectDescription. Basically 3 strings of metadata describing each of a class' member variables (and hopefully functions) so that the class can report to a query from another class what properties it has available for access at run time. Here is what I have and t...

Pointers to pointers
How can you use a "pointer to a pointer" as a two dimensional array using 'new' and 'delete' rather than 'malloc' and 'free'? Thanks, Jonas Jonas Cord wrote: > How can you use a "pointer to a pointer" as a two dimensional array > using 'new' and 'delete' rather than 'malloc' and 'free'? Pretty much the same. int main() { int** data; data = new int*[100]; for (int i = 0; i < 100; ++i) data[i] = new int[100]; //use it for (int i = 0; i < 100; ++i) delete []...

pointer of pointer
Hi I have a structure, B_t is another structure typedef struct{ int len; unsigned char code[12]; B_t *b; }A_t Now I need to pass A_t into a function to evaluate I use pointer of pointer void evaluate(A_t **a) My question is how to evaluate the component of this structure (*a)->b??? seems not right Thanks a lot! <qianz99@gmail.com> wrote in message news:1178915812.306611.242380@y80g2000hsf.googlegroups.com... > Hi > > I have a structure, B_t is another structure > > typedef struct{ > int len; > unsigned char code[12]; > B_t *b; > }A_t > >...

Web resources about - pointer to a pointer - comp.mac.codewarrior

Plaxton Pointer - Wikipedia, the free encyclopedia
The Plaxton Pointer (originally known as the Reeve Burgess Pointer , and later as the TransBus Pointer and Alexander Dennis Pointer ) is a successful ...

Michael Pointer (@michaelpointer) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

Thread: I'm looking for pointers to a Google Maps API overview.
... outline for a map, making it super-easy to edit, and also to have it in the most convenient form for someone browsing over the data. Any pointers ...

Anchor Pointer — GPS Compass & Friend Navigator on the App Store on iTunes
Get Anchor Pointer — GPS Compass & Friend Navigator on the App Store. See screenshots and ratings, and read customer reviews.

Kobe Bryant 45 Points (NBA Record 12 Three-Pointers) vs Seattle Super Sonics - Highlights 07/01/2003 ...
Los Angeles Lakers vs Seattle Super Sonics 07/01/2003 Ignore Tags : mix derrick rose mix miami heat new york knicks mix thunder lebron james ...

Shark warning as white pointers cruise off Perth beaches
Large schools of salmon are bringing danger to Perth's beaches and waters as Great White Sharks follow the fish along the coast.

Footy kicks logic for a nine-pointer
Apart from hilarious change strips, footy’s number one growth industry appears to be inexplicable phenomena

Juvenile white pointer shark nursery located off beaches around Newcastle
... nowhere to be seen. The stretch of coast just north of Newcastle has long had a reputation as being a “nursery” for juvenile white pointer sharks. ...

Esperance shark attack survivor Sean Pollard recalls how he fought off white pointer - PerthNow Search ...
BUNBURY shark attack survivor Sean Pollard says he feels lucky to be alive after his miracle escape from a white pointer near Esperance.

Georgia State Panthers coach Ron Hunter falls off stool as son RJ Hunter nails match-winning three-pointer ...
Georgia State coach Ron Hunter fell out of his chair. The rest of America probably did, too.

Resources last updated: 1/27/2016 8:09:41 PM