Error "error: invalid types ‘char[int]’ for array subscript" in C++.
Hello, I have this code that gives me the error from the title: This is problem statement: Given a string of "s" consisting of two words separated by space (first name and name), write the two words formatted so that the first word (first name) starts with a capital letter and the rest of the characters are written in normal letters and the second word (name) should be written in capital letters only Input: s "mAriN Ion" And the expected output must be : s2 "Marin ION" #include <iostream> #include <cstring> #include <string.h> using namespace std; int main() { char s[50], s2[50]; cin.getline(s, 50); char *pp = strtok(s, " "); while (pp != NULL){ pp = strtok(NULL, " "); } tolower(pp[1]); pp[1][1] = char(int(pp[1][1]) - 32); toupper(pp[2]); strcat(s2, pp[1]); strcat(s2, pp[2]); cout << s << "\n" << s2; return 0; } https://code.sololearn.com/c1KqiUbbqlEc/#cpp Someone can explain me how to solve this error. Thank you very much.