I need an array of arrays of string in my programm. I am declaring it so:
string edges[N][N] = {
{"0", "A", "0", "B", "E", "0", "0", "P1", "0"},
{"A", "0", "D", "I", "0", "0", "0", "0", "0"},
{"0", "D", "0", "0", "0", "H", "F", "0", "0"},
{"B", "I", "0", "0", "0", "H", "0", "0", "0"},
{"E", "0", "0", "0", "0", "0", "0", "P2", "0"},
{"0", "0", "H", "H", "0", "0", "0", "0", "P4"},
{"0", "0", "F", "0", "0", "0", "0", "0", "P3"},
{"0", "0", "0", "0", "0", "0", "0", "0", "0"},
{"0", "0", "0", "0", "0", "0", "0", "0", "0"},
};
Its okay, when I am trying to access strings with 1-letter value (A or B etc), but If I try to access string with 2-letters value, like edges[0, 7] (value is "P1"), programm will output 0. What's wrong?
It working fine if element is 1-letter like A, B, C, etc, but fail with P1 or P2.
Full programm listing and working programm is here http://ideone.com/ZMiVPE
edges[0][7]?edges[0, 7]is the same asedges[7].edges[0][7]. Sorry. @ValekHalfHeart, sorry for my bad english, I eddited my question.[0], soedges[0][8]in an array of[9][9]is the last entry on the first line... "0". The same thing in your program on ideone... the indices you're printing are legitimately "0" elements in your array. See ideone.com/OywUMIcout << " -(" << edges[next][prev] << ")-> " << names[tmp] << " : " << prev << " : " << next;<-- note you printprevbeforenext, but you index in the opposite order. If you look up[next][prev]e.g.[8][5]you'll find they are "0".