Pointers gone mad!
- From: Robby <Robby@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 12 Dec 2007 11:01:00 -0800
Hello,
This is a simple questions about pointers! I can't believe I am asking this.
But here it goes. Please note that an integer is 8 bits long (1 byte)! Please
view question which is commented in code below.
=====================================Calling routine!
int spiA0=0,spiA1=0,spiA2=1;
//INCREMENT_ADDRESS BY AMOUNT OF INCREMENTATIONS REQUIRED
INC_ADDR(16,&spiA2, &spiA1,&spiA0);
=========================================Function!
void INC_ADDR( //***INCREMENT_ADDRESS***
int INCBY, //AMOUNT OF INCREMENTATIONS REQUIRED
int *A2, //MSB OF MESSAGE ADDRESS IN PAR FLASH
int *A1, //MIDSB OF MESSAGE ADDRESS IN PAR FLASH
int *A0) //LSB OF MESSAGE ADDRESS IN PAR FLASH
{
int i;
for(i=0;i<INCBY;i++)
{
if((*A0)==255) //Before A0 turns to 0, statement is true
{(*A1)++; //Increment central byte of flash adress
if((*A1)==255) //Before A1 to 0, statement is true
{ (*A2)++; //Increment MSBYTE of flash adress
}
}
/////////When the next line is executed (While i=0 during 1st iteration of
for loop)
//////// A0 increments to 1. But why does A1 get assigned the value of
256?????
(*A0)++;
}
}
================================================
Confused!
--
Best regards
Robert
.
- Follow-Ups:
- Robby, __int8 limited to: -128 to 127.
- From: Jeff☠Relf
- Re: Pointers gone mad!
- From: Doug Harrison [MVP]
- Re: Pointers gone mad!
- From: Norbert Unterberg
- Re: Pointers gone mad!
- From: Igor Tandetnik
- Robby, __int8 limited to: -128 to 127.
- Prev by Date: Re: template function issue
- Next by Date: DLL declarations created by VC++ app wizard
- Previous by thread: Re: template function issue
- Next by thread: Re: Pointers gone mad!
- Index(es):
Relevant Pages
|