To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.handyboardOpen lugnet.robotics.handyboard in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Handy Board / 5894
5893  |  5895
Subject: 
Re: Help with pointers
Newsgroups: 
lugnet.robotics.handyboard
Date: 
Thu, 25 Mar 1999 18:42:18 GMT
Original-From: 
Keith Hearn <khearn@STOPSPAMlegato.com>
Viewed: 
1039 times
  
In message <36FA5DB7.32ABEF8@zhwin.ch>, Thomas Hauri writes:
Hi all
little question:

How can I ad a value to a pointer ??

int *px, x;

px = &x;

px = px + 1;   (????? pointing to the lowbyte of x for example)

When you do pointer arithmatic, you work in increments of what the
  pointer points to. So if you have a pointer to an int, as in the above
  example, when you add one to it, you actually make it point to the
  next int, not the next byte or word.

This is so that you can have an array of something and move a pointer
  through the array by ioncrementing it without having to pay
  attention to how big your array elements are.

If you want to point to the low byte of x, you might be able to do
  something like this:

  int x;
  char * p; /*this assumes that a char is one byte*/

  p = &x;
  p++;

Be warned that that is pretty non-portable code. What it actually does
  depends on how big int and char are with the specific
  compiler/machine combination, and details like byte ordering within
  words.

The above all applies to "normal" C. I'm not exactl sure how IC would
  handle it.

  Keith Hearn
  khearn@legato.com


Is it just NOT possible with IC or am I missunderstanding anything ????

Thanks for any help.

--
Thomas Hauri
ZHW Zuercher Hochschule Winterthur
University of applied sciences
Technikumstr.9 /PF
CH-8401 Winterthur
Switzerland

Phone : +41 52 267 74 79
Fax    :  +41 52 268 74 79
Mail  :   Thomas.Hauri@zhwin.ch
HP    :   http://www.zhwin.ch





Message is in Reply To:
  Help with pointers
 
Hi all little question: How can I ad a value to a pointer ?? int *px, x; px = &x; px = px + 1; (????? pointing to the lowbyte of x for example) Is it just NOT possible with IC or am I missunderstanding anything ???? Thanks for any help. -- Thomas (...) (26 years ago, 25-Mar-99, to lugnet.robotics.handyboard)

2 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR