You could always convert it, then see how many characters there are.

Or, you could use a stringstream to do it for you:
Code:
#include <iostream>
#include <sstream>
#include <iomanip>

void somecode() {
    ostringstream oss;

    oss << setw(8) << setfill('0') << 6574;

    string whatever = oss.str();
}