What's special about integer pointers (but any pointer type really) is that you can assign to them NULL
a non-integer sort of value; whereas an integer has to, no matter what, store an integer, be it a positive or negative one (correct me if I'm wrong), and no NON-integer values.
Could you then make use of this 'special' feature of pointers (that of being a variable that can store integers and a NON-integer value: NULL
) to at the same time store integer values (via their literal actual value, like instead of an address, it would store a signed/unsigned integer) and be a sort of boolean
-- where a NULL pointer
would signify false
& a valid pointer
(i.e one that is holding an integer) (but not really valid ofc, just one that isn't NULL
) would signify true
.
Note: The pointer is absolutely never used to access a memory location, just to store an int.
(Ofc this is just for a particular use case, not that you would do this in regular code)
(If you really want to know) I'm trying to make a recursive function, and want the return value of the function to return an integer but also want to keep track of a condition, so I also want it to return a boolean, but you obviously can only return a single argument... so could passing an integer pointer, a variable that can do both at once, be the solution ?
I thought of other ways (stucts, arrays.. ), but curious if doing it w/ an integer pointer could be a plausible way.