View Single Post
Old 07-14-2012, 09:42 PM   #2
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299993
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
I'm reading here: http://en.wikibooks.org/wiki/C_Progr..._dereferencing

Pointers in Function Arguments

Often we need to invoke a function with an argument that is itself a pointer. In many instances, the variable is itself a parameter for the current function and may be a pointer to some type of structure. The ampersand character is not needed in this circumstance to obtain a pointer value, as the variable is itself a pointer. In the example below, the variable pStruct, a pointer, is a parameter to function FunctTwo, and is passed as an argument to FunctOne. The second parameter to FunctOne is an int. Since in function FunctTwo, mValue is a pointer to an int, the pointer must first be dereferenced using the * operator, hence the second argument in the call is *mValue. The third parameter to function FunctOne is a pointer to a long. Since pAA is itself a pointer to a long, no ampersand is needed when it is used as the third argument to the function.
Code:
 int FunctOne( struct SomeStruct *pValue, int iValue, long *lValue )
 {
    /*  do some stuff ... */
    return 0;
 }
 int FunctTwo( struct someStruct *pStruct, int *mValue )
 {
    int j;
    long  AnArray[25];
    long *pAA;
 
    pAA = &AnArray[13];
    j = FunctOne( pStruct, *mValue, pAA );
    return j;
 }
Um... What? Read's it several more times. sigh. get's tea

Last edited by twobob; 07-14-2012 at 09:57 PM.
twobob is offline   Reply With Quote