The palace has revealed King Charles spent time in hospital after experiencing temporary side effects from his cancer treatment.