Go to Post Welcome to ChiefDelphi a month before Kick-Off. This is an annual traditional experience for quite a few regulars. - synth3tk [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #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.
  #2   Spotlight this post!  
Unread 08-12-2006, 16:43
Qbranch Qbranch is offline
wow college goes fast.
AKA: Alex
FRC #1024 (Kil-A-Bytes)
Team Role: Alumni
 
Join Date: Apr 2006
Rookie Year: 2006
Location: Indianapolis
Posts: 1,174
Qbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond repute
Re: incrementing

*chuckle

well yeah theres lots of ways to say it, but it all compiles the same. personally, <operator>= is my favorite. but hey, thats just me.

see you all later... i'll be rockin out to them xm seasonal channels

-Q
__________________
Electrical Engineer Illini
1024 | Programmer '06, '07, '08 | Driver '08
  #3   Spotlight this post!  
Unread 09-12-2006, 23:40
TimCraig TimCraig is offline
Registered User
AKA: Tim Craig
no team
 
Join Date: Aug 2004
Rookie Year: 2003
Location: San Jose, CA
Posts: 221
TimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to behold
Re: incrementing

Quote:
Originally Posted by Alan Anderson View Post
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.
That's true, however using a pointer that way for general arithmentic and casting it back to an int type would definitely be abusive and the programmer need not apply for a job in my shop.

One place I've used pointer arithmetic along those lines with the PIC is to be able to treat the PWM outputs as an array. Although there the increment in address defaults back to 1.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 01:21.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi