Listing 1: Unsigned integer conversion
/* ///////////////////////////////////////////////////////////// * * ... * * Extract from stlsoft_integer_to_string.h * * www: http://www.synesis.com.au/stlsoft * http://www.stlsoft.org/ * * Copyright (C) 2002, Synesis Software Pty Ltd. * (Licensed under the Synesis Software Standard Source License: * http://www.synesis.com.au/licenses/ssssl.html) * * ... * * ////////////////////////////////////////////////////////// */ ... template <class C, class I> inline const C *unsigned_integer_to_string( C *buf, size_t cchBuf, I i) { C *psz = buf + cchBuf - 1; // Set psz to last char *psz = 0; // Set terminating null do { unsigned lsd = i % 10; // Get least significant // digit i /= 10; // Prepare for next most // significant digit --psz; // Move back *psz = get_digit_character<C>()[lsd]; // Place the digit } while(i != 0); return psz; } End of Listing