I’ll toss in my two bits… C++ question on Straight Dope, who knew?
I’ll suggest a C++ solution rather than the C-within-C++ solutions suggested so far (just as a variant).
First, use an ostrstream object as a stream (like the cout object used in C++ for console I/O)… #include <ostrstream> is needed:
ostrstream stringout;
Output your variable via this object:
stringout << counter;
Extract the assembled string object:
string counterstring;
counterstring=stringout.str();
At this point, counterstring contains the string representation of the counter. This sequence of events is equivalent so far to using the itoa routine. But I’m not even sure itoa is ANSI standard C/C++… I’m pretty sure the standard way would normally use sprintf, and a character array as the destination. Anyway, moving on with my C++ solution.
You can iterate through counterstring as if it were an array of chars, up to a size limit of counterstring.size() and replacing all ‘1’ with ‘*’ (string objects are not necessarily null terminated as far as I know).
Alternately, you can simply output the characters as you go, in the loop, but outputting a ‘*’ if a ‘1’ is at the current position.
Personally, since I’m starting to get a serious handle on the Standard Template Library, I suggest (having #include <algorithm>):
replace(counterstring.begin(),counterstring.end(),‘1’,’*’);
using counterstring as a standard STL container which has a begin() iterator value and an end() iterator value.
Normally I wouldn’t produce code for homework either, but your professor probably won’t believe you wrote this if you pull STL code out of a hat without showing an understanding of it. 
Anyway, having produced a replaced counterstring, you can now output it via the cout object:
cout << counterstring << endl;
The nice thing about doing it using the ostrstream and string classes (even if you don’t use the replace algorithm) is that you avoid monkeying around with straight C arrays which are occasionally fraught with peril.
Yes, this isn’t the most efficient solution, but the code is clean. Efficiency can be gained by pre-creating the string object and passing it into the ostrstream object (so only one is ever created). Also, in a loop, the ostrstream can be reused if it is reset so it doesn’t have to be created or destroyed either. Lots of options for optimizations if necessary.
Or, you can use a straight C array of sufficient size, and sprintf, to remain cross-platform (behaves like printf, but with a new first parameter being a character buffer/array). I don’t personally condone using the (as far as I know) nonstandard itoa.
Comments?