I have a struct, and I have been passed a pointer to it to the function I'm in, how do I then use this pointer to access stuff in the struct?
Thanks
This is a discussion on Using pointers to access something in a struct within the C Programming forums, part of the General Programming Boards category; I have a struct, and I have been passed a pointer to it to the function I'm in, how do ...
I have a struct, and I have been passed a pointer to it to the function I'm in, how do I then use this pointer to access stuff in the struct?
Thanks
I'm not sure what you're saying, post some source code.
do you mean with the "->" operator?
fooptr->member
Is the pointer equivalent of
foo.member
You can also do
(*fooptr).member or fooptr[0].member if you want, though the latter is preferred if you really do have a pointer to an array of structures.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.