View Single Post
  #3   Spotlight this post!  
Unread 17-02-2004, 13:17
Jeff McCune's Avatar
Jeff McCune Jeff McCune is offline
Alpha Geek
#0677 (The Wirestrippers)
Team Role: Mentor
 
Join Date: Jan 2003
Location: The Ohio State University
Posts: 67
Jeff McCune is on a distinguished road
Send a message via ICQ to Jeff McCune Send a message via AIM to Jeff McCune
Re: Pointers to structs?

After some testing in gcc, I figured it out. The more descriptive errors helped. The page I was reading was incorrect about the ordering of the type name versus the variable name. I'm actually passing a bitmask value that I #defined as a bitmask, but I just did it this way so it's easier for people to understand the pointer stuff that's going on. It's so nice having full ansi C.

Code:
struct relay_type { int fwd; int rev};
struct relay_type ball_arm_lower;

void set_relay (struct relay_type *relay, int fwd, int rev)
{
  relay->fwd = fwd;
  relay->rev = rev;
}

main()
{
  update_inputs ();
  set_relay (&ball_arm_lower, 1, 0);
  update_outputs ();
}
__________________
Team 677 - The Wirestrippers - Columbus School for Girls and The Ohio State University
EMAIL: mccune@ling.ohio-state.edu

...And all you touch and all you see
Is all your life will ever be...