Ok guys,
I've been wasting 30min on that piece of code, ridiculously easy yet it does not gives me the same address....
yet it should...
I just want to understand why...
Here goes the code
void * target=NULL;
void * temporary=NULL;
// that is a pointer to a buffer (some might say array)
// of N struct of type DS_GEP_EPoch
target=datastore.Orbit->Epoch;
// now I wanna move in memory
// from the first struct pointed by
// target to the struct number (v->epoch_number)
// v->epoch_number is an int btw...
target+=(v->epoch_number)*(sizeof(DS_GEP_Epoch));
// Why not doing all that in on line to save some space
// I actually have to do that kind of thing a lot
// of time and therefore won't mind reducing the numbers
// of line a bit...
temporary=datastore.Orbit->Epoch + ((v->epoch_number)*(sizeof(DS_GEP_Epoch)));
// well... let's print up the address
printf("target:\t%d\ntemporary:\t%d\n", target, temporary);
/*
the result of the printf for instance:
target : 1076559741
temporary : 1494148727
*/
// It does not work... the result are different.
// Bear in mind I'm not using any fork or threads
// only on single process.
// I'm pulling my hair off...
I've been wasting 30min on that piece of code, ridiculously easy yet it does not gives me the same address....
yet it should...
I just want to understand why...
Here goes the code
void * target=NULL;
void * temporary=NULL;
// that is a pointer to a buffer (some might say array)
// of N struct of type DS_GEP_EPoch
target=datastore.Orbit->Epoch;
// now I wanna move in memory
// from the first struct pointed by
// target to the struct number (v->epoch_number)
// v->epoch_number is an int btw...
target+=(v->epoch_number)*(sizeof(DS_GEP_Epoch));
// Why not doing all that in on line to save some space
// I actually have to do that kind of thing a lot
// of time and therefore won't mind reducing the numbers
// of line a bit...
temporary=datastore.Orbit->Epoch + ((v->epoch_number)*(sizeof(DS_GEP_Epoch)));
// well... let's print up the address
printf("target:\t%d\ntemporary:\t%d\n", target, temporary);
/*
the result of the printf for instance:
target : 1076559741
temporary : 1494148727
*/
// It does not work... the result are different.
// Bear in mind I'm not using any fork or threads
// only on single process.
// I'm pulling my hair off...