Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualParadigm Shifter

Posted 13 March 2013 - 04:10 PM

That's because it's a pointer not an array... if you do

 

pSrc[offset] that's just shorthand for *(pSrc + offset) but you add 4 to pSrc each iteration so if you have

 

 

char myCharArray[10000] = { some data };

 

char* pSrc = myCharArray;

pSrc[0] = 10;

pSrc += 4;

pSrc[0] = 11;

 

that's the same as writing 10 to myCharArray[0] and 11 to myCharArray[4].

 

EDIT: Oops, mixed up order of pSrc and pBase in first attempt.

 

EDIT2: Changed pBase into myCharArray... easier to understand...


#5Paradigm Shifter

Posted 13 March 2013 - 04:08 PM

That's because it's a pointer not an array... if you do

 

pSrc[offset] that's just shorthand for *(pSrc + offset) but you add 4 to pSrc each iteration so if you have

 

 

char pBase[10000] = { some data };

 

char* pSrc = pBase;

pSrc[0] = 10;

pSrc += 4;

pSrc[0] = 11;

 

that's the same as writing 10 to pBase[0] and 11 to pBase[4].

 

EDIT: Oops, mixed up order of pSrc and pBase in first attempt.


#4Paradigm Shifter

Posted 13 March 2013 - 04:08 PM

That's because it's a pointer not an array... if you do

 

pSrc[offset] that's just shorthand for *(pSrc + offset) but you add 4 to pSrc each iteration so if you have

 

 

char pBase[10000] = { some data };

 

pSrc = pBase;

pSrc[0] = 10;

pSrc += 4;

pSrc[0] = 11;

 

that's the same as writing 10 to pBase[0] and 11 to pBase[4].

 

EDIT: Oops, mixed up order of pSrc and pBase in first attempt.


#3Paradigm Shifter

Posted 13 March 2013 - 04:07 PM

That's because it's a pointer not an array... if you do

 

pSrc[offset] that's just shorthand for *(pSrc + offset) but you add 4 to pSrc each iteration so if you have

 

pSrc = pBase;

pSrc[0] = 10;

pSrc += 4;

pSrc[0] = 11;

 

that's the same as writing 10 to pBase[0] and 11 to pBase[4].

 

EDIT: Oops, mixed up order of pSrc and pBase in first attempt.


#2Paradigm Shifter

Posted 13 March 2013 - 04:07 PM

That's because it's a pointer not an array... if you do

 

pSrc[offset] that's just shorthand for *(pSrc + offset) but you add 4 to pSrc each iteration so if you have

 

pSrc = pBase;

pSrc[0] = 10;

pSrc += 4;

pSrc[0] = 11;

 

that's the same as writing 10 to pBase[0] and 11 to pBase[4].


#1Paradigm Shifter

Posted 13 March 2013 - 04:06 PM

That's because it's a pointer not an array... if you do

 

pSrc[offset] that's just shorthand for *(pSrc + offset) but you add 4 to pSrc each iteration so if you have

 

pBase = pSrc;

pSrc[0] = 10;

pSrc += 4;

pSrc[0] = 11;

 

that's the same as writing 10 to pBase[0] and 11 to pBase[4].


PARTNERS