Not sure if I'm overthinking for this, but how would I return something undefined when the parameter is not in the range that needs to be?
I'm trying to do:
uint64_t function(uint64_t Value, uint64_t N) {
uint64_t result = 0;
if (N > 0){
//do something;
return result;
}
else{
return result is undefined;
}
}
How do I return N is undefined?
One solution is to return a status and use an OUT parameter like so:
bool function(uint64_t Value, uint64_t N, uint64_t *result) {
if (N > 0){
//do something;
*result = 31337;
return true;
}
else{
return false;
}
}
Then when you call this function you check that the function returns true before using the result.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With