As JaredPar said, change ptr's declaration to
const char* ptr;
And it should work. Although it looks surprising (how can you iterate a const pointer?), you're actually saying the pointed-to character is const, not the pointer itself. In fact, there are two different places you can apply const (and/or volatile) in a pointer declaration, with each of the 4 permutations having a slightly different meaning. Here are the options:
char* ptr; // Both pointer & pointed-to value are non-const
const char* ptr; // Pointed-to value is const, pointer is non-const
char* const ptr; // Pointed-to value is non-const, pointer is const
const char* const ptr; // Both pointer & pointed-to value are const.
Somebody (I think Scott Meyers) said you should read pointer declarations inside out, i.e.:
const char* const ptr;
...would be read as "ptr is a constant pointer to a character that is constant".
Good luck!
Drew