or you could pass in the length of the string:Code:void PrintChar(const char* szText) { // as long as szText is not pointing to a null char while ( szText != '\0' ) { // print the current character // and move the pointer to the next one PrintChar( (*szText++) ); } }
Code:void PrintChar(const char* szText, int length) { for(int i = 0; i < length; ++i) PrintChar(szText[i]); }





Reply With Quote