I'm trying to write a simple short code that takes a few input characters and finds each character's number in the alphabet. My goal is that it returns an array with these indices, so that for the fairly random input word: "pepper", it would return [15,4,15,15,4,17]. However, I get some strange things too. It sort of works, but not quite.
Here's the code:
@LowestOne: Thanks! That explains a few things indeed! But if I want it to return the entire array when this function is called elsewhere, would it work if I set the return to: return indices;?
@vlad: That cout-loop was just to check if the first few integers were right -- as LowestOne pointed out, it would be more complete if it used count-1 rather than 4 (which was very arbitrary) :)