do you want to take into account the possibility of a nullptr argument?
you could use the strlen() function instead of your while loop for the const char* case
void print(const char* cp) {
Serial.println(strlen(cp));
}
Similar functions exist for PROGMEM data (strlen_P or strlen_PF)
a suggestion: instead of being void the return type could be size_t and you return the number length of what has been printed?
EDIT: gfvalvo was faster ![]()