The -1 is for not found, because it is an invalid index in array. So lookup the array and fill the position into the answer array. At best you initialize all elements the answer array with -1.
What if the char is more than 2x in the array?
Use some C++ tutorial to learn the language like accessing an array and screen output like Learn C++
. Install Visual Studio.