It is perfectly legal to modify a character in a string like that - however, it is not legal to modify a string constant.
That code sets str to point to the string literal "hello world" in the read only data segment of your program.
char* str = "hello world";
You'll have to malloc some memory and use strcpy(), or use an array.
char* filename = new char;
Personally, I would just use a std::string:
char filename = "frame0000.tif";
Hope that helps.