I tried searching this site for this, and while people have had this error, I can't seem to find the cause in my code.
I'm trying to get a last name from the user, validate it, and uppercase/lowercase the necessary letters. I'm using a function for this, and I know that the error is in the "for" loop thanks to system pause.
If MAX is greater than the name length, the for loop will be trying to access elements of name that don't exist.
Edit: With a do..while loop, the code runs through at least once. It looks like your conditions - name is longer than max, or name is empty, should kick in before you get to the for loop?
Counting from 1 to MAX assumes that the length of string name will be equal to or greater than MAX. If the string is shorter than MAX, trying to read name[count > size of name] will result in the error you describe.
You need to limit the count in line 18 to the size of string "name" instead of MAX.