How do you get that error? Is it a compiler error? A linker error? A runtime error?
What is the exact error message?
It is good to learn to provide the essential details when asking questions. Sometimes you can even spot the error yourself, when gathering the details.
In this case, how long is (a piece of) string? What are the valid indices for an N-element long array in C++?