arrow operator

From: Jason (jasclz_at_aol.com)
Date: 10/29/03


Date: 29 Oct 2003 07:24:28 -0800

Hi everyone:

I was trying to pass a pointer to a structure to a function, where the
pointer is pointing to one of the members in the structure, is this
possible???

For Example:

struct reptile *animalPtr

foo(animalPtr->snakes);
foo(animalPtr->aligator);
/* here now animalPtr->snakes == 100 and
            animalPtr->aligaotr == 100 */

Within foo, I was hoping to be able to change the value of the object
in the structure.

For Example:

foo(???){ /* not sure what the parameters will be */

  if(blah < blah2)
     ??? = 100 /* where ??? is the input to this function */

}

I was wondering would this work? If so, what would my ??? in my
example be? How would I be able to change the value of ??? ? If this
is not possible, what how should I go about doing this? Thanks in
advance for all replies.

-Jason



Relevant Pages

  • Re: Deferencing void pointer
    ... The variable my_list has an address in memory. ... That type is pointer to (whatever it's the ... You are specifying that it will have an argument of type pointer to ... now *list simply means "the thing that list is pointing to". ...
    (comp.lang.c)
  • Re: Aliases in C
    ... it begins with a successfull realloc: ... If the mechanism decreases the size or requires a new allocation, ... whatever q is pointing at gains one. ... If the pointer values are ...
    (comp.lang.c)
  • Re: Link List
    ... emanshu, Munish Nayyar wrote: ... nodeis pointing to some previous node and i want to search for node which is pointing back to previous nodes. ... Say you have pointer to node X, which in turn points to another node Y. 2. ...
    (comp.lang.c)
  • Re: struct stat *stbuf seg fault
    ... Here you are using an uninitialized pointer and passing it to ... a function that expects to write data where the pointer is pointing. ... Try declaring a struct stat and making stbuf point at it. ... >When passed a none existant directory name, ...
    (comp.lang.c)
  • Re: Can somebody give me an example how to obtain a files size?
    ... > so it is pointing to a random memory location. ... > You still hve not initialized the variable filename so this line is ... especially the uninitialized pointer made it very clear to me why the program was segfaulting. ...
    (comp.programming)