cout << "\n What is the index of the character you want to change? ";
cin >> ind;
if (a[ind] == '\0')
cout << "That position is outside the bounds of the string. String unchanged.";
cout << "\nWhat character do you want in that position? ";
char New;
cin >> New;
Are you using C-style strings (char[] str = "Hello World") or C++ strings (std::string str = "Hello World") ? edit: Question is irrelevant.
if (a[ind] == '\0')
What happens if the index is outside the bounds of the string?
i got this far
You're almost there! The solution is actually much easier than you think.
1 2 3 4 5 6 7 8
// Let's say you have an array of integers.
int arr[] = { 2, 7, 9, 3, 8 };
// How would you change the integer at index 2 of this array?
/*
A string is an array of characters. Applying the same logic as above,
how would you replace the nth index of the string?
*/
if (a[ind] == '\0') the program will run again and ask new q!
my question is how I change it if I don't know which index the user will enter?
int array [3] = to new index that if i know exactly which index