For functions returning a pointer, a NULL pointer can be used as an out of band value( the caller of course should check the pointer for NULL, before dereferencing it):
Item *pop_last_item()
{
if (!item_stack_size) {
return NULL;
} else {
return ItemStack[--item_stack_size];
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…