Quote Originally Posted by eightyfive View Post
but, I think you are very closed to the INT type, consider it could be done using another data type, just think about it. why so closed to the INT type?
When you post code, it will get commented on.

The code you posted will not work on a system that has 64-bit pointers and 32-bit integers. Practically all Windows C++ compilers, including VC++, operate this way for 64-bit programs. So your code when compiled as a 64-bit executable with one of the most popular compilers used around the world would not work, or at the very least, not work reliably due to truncation.
his problem involved the fact that his teacher didn't allow him to use arrays, pointers, dynamic allocation or even structs.
but you didn't know that part, so it's okay
If that's the case, then there is no guarantee any of your code works, because you rely on an implementation detail, and that is that variables when declared "together" are contiguous.

The only way you can guarantee contiguousness is to write code that guarantees it. An array, dynamically allocated memory, etc. guarantee that what you have is a contiguous block of memory. Declaring variables one after the other does not guarantee this.

Regards,

Paul McKenzie