[Tutor] Pointer handling

Abel Daniel abli@freemail.hu
Wed Jun 11 14:34:03 2003


Jimmy verma wrote:
> Hello *.*
> 
> I am having a problem with handling pointers.
> 
> I have a function like this:
> XYZ is a struct.
> 
> ABC( XYZ *aa)
> {
>       XYZ *bb;
>       bb = &aa[no];    // no is some integer value.
 This is the same as "bb = aa + no;", right?
>       /*Do sthing */
>        HHH(bb, aa, no);             // values are used in some function
> 
> }
> 
Well, your C function gets not one XYZ, but a list of XYZs. (Or, more
precisely, a pointer which you handle as pointing to the first element
in a list.) So in python it would look like:

def ABC(l):
    # do something
    g = l[no:]
    HHH(g, l, no)

Of course, this might not be what you want, depending on what is
happening in the /*Do sthing*/ part, and what HHH does.
(For example, the C example doesn't create a new list, my python version
does.)

Abel Daniel