Thread: incrementing
View Single Post
  #1   Spotlight this post!  
Unread 08-12-2006, 15:25
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: incrementing

Quote:
Originally Posted by TimCraig
i++ and its prefix version ++i only add one. There's no way to increment by a different value using this notation...
Here's something few people know about C: pointer arithmetic scales integers by the size of the type being pointed to. For example, if ptr is a pointer to an int, then ptr++ will add 2 (or whatever the native size of an int is for a particular target). If parr is a pointer to a structure of twelve bytes, parr = parr + 3 will add 36.

But don't abuse this fact. Pointer arithmetic is not necessarily something useful for programming PIC processors to control FRC robots.