C++ Array Error: Access violation reading location 0xC0000005 -


for reason, when try print out array of strings has error:

unhandled exception @ 0x0f767ea6 (msvcp120d.dll) in project1.exe: 0xc0000005: access violation reading location 0x73f6b6ff.

here code generates error:

#include <iostream> #include <string>  using namespace std;  int main() {     const int numitems = 6;     string itemnames[numitems] = { "boots", "swords", "helmets", "kittens", "poleaxes", "leggings" };      cout << "*** welcome item shop! ***\n";      (int = 0; < numitems; i++)     {         cout << itemnames[numitems] << endl;     }      cout << "**********\n\n";     cout << "what buy?\n";      system("pause");     return 0; } 

i using visual studio 2013, way.

for (int = 0; < numitems; i++) {     cout << itemnames[numitems] << endl; } 

you may want cout << itemnames[i] << endl;. otherwise itemnames[numitems] out-of-bound.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -