Bad Access Error when using Array Index method for Vector String [closed]

  c++, string, vector

Just getting some practice with vectors so the code intent here is just to output the contents of the two vectors shown. When I use the pushback method, I am able to enter elements to the vector just fine, or if I define the vector elements when intitaializing, that compiles as well. I get a "EXC_BAD_ACCESS" error when using the Array Index Method for defining elements for the vector; can anyone tell me why?

For reference I am using Xcode on MacOS using Apple silicon if that makes a difference.

I am posting all 3 cases.

Case 1: Using Pushback – Runs
Case 2: Defining Elements in Vec Initialization – Runs
Case 3: Using Array Index Method – Doesn’t Run

Source: Windows Questions C++

LEAVE A COMMENT