I mean this in a light-hearted but serious manner.
Dyslexicbloke:
Making assumptions about how variables will be stored in memory is a very dubious practice.
I thought as much which is why I asked ... However it appears to be working, all be it with a simple test.
This means you got lucky, is all.
Seriously, this is pure luck that you can't rely on. The danger is to translate "luck" into "learning", because you've ended up handicapping yourself in the future.
Making assumptions about how variables will be stored in memory is a very dubious practice.
100% correct. Your code should be reliable, not lucky.
Incrementing a pointer only makes sense when the pointer points to an array of items. If you create discrete instances, even if they are adjacent in memory, you can't iterate through the instances by incrementing a pointer.
Yes, you discovered that the second part of what was said here is not technically correct, but please understand it's 100% correct in spirit.
Incrementing pointers only works as expected when the things that are being pointed to are adjacent in memory. Arrays force this behaviour. It's reliable. Therefore, "Incrementing a pointer only makes sense when the pointer points to an array of items" is correct in all aspects.
You did get a good lesson, that you yourself predicted:
xVar BatVolts; // New instance of xVar, first instance
int JustJunk1 = 10; // Junk to ensure that the two instances of xVar are not together, at least logically, who knows what the compiler does.
"who knows what the compiler does."
You got that exactly right. Combine this with what you were told before and turn it into a mantra — "Don't make assumptions about how variables will be stored in memory. Who knows what the compiler does."
In this case what would seem "logical" didn't pan out. The compiler did some optimization and decided that your "logically" wasn't logical, and rearranged the order of variables. It just happened to place the two structs next to each other.
This is what I mean when I said you got lucky.
Anyhow, I hope this is taken in the friendly spirit that's intended.