Advertisement

Altering a multi-dimensional vector?

Started by September 28, 2002 10:51 AM
1 comment, last by Cestps 22 years, 1 month ago
How can i alter a multi-dimensional vector after initializing it? something like this: bool bVector[4][4]; bVector = { {0,1,1,0}, {0,1,0,1}, {0,1,1,0}, {0,1,0,1}}; This, however, generates a lot of errors telling me "C:\Bengtris\Main.cpp(54) : error C2143: syntax error : missing '';'' before ''}''". I''m using MSVC++ 6.0. -The porridge is broken. -Oh my god! How can something like porridge break? -Weird, no?
Abnormally large and solar energy charged!
bool bVector[4][4] = {{false,true,true ,false},                      {false,true,false,true},                      {false,true,true ,false},                      {false,true,false,true}};


The true false thing, well, I just like it cuz it improves readibility...

You can only assign variables like that if they are part of their declaration.

...note:
I''m somewhat guessing here, I haven''t tested it tho, but I think I''m right...
~~~~~Screaming Statue Software. | OpenGL FontLibWhy does Data talk to the computer? Surely he's Wi-Fi enabled... - phaseburn
Advertisement
You can''t directly. Build a more complex datatype around the array.


  int testarray[3];void test(void){ testarray = { 1,2,3 }; // no no }  


If you want to initialize it when you define it, the syntax

  bool bVector[4][4] = {{0,1,1,0},{0,1,0,1},{0,1,1,0},{0,1,0,1}};  

Works fine.

This topic is closed to new replies.

Advertisement