two dimensional array initialization

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello everyone,


I find to initialize two dimentional array in Visual Studio, I have to
specify the number of elements. For example,

Code:
const char foo[][] = {"hello",  "world"}; // compile error
const char goo[][64] = {"hello",  "world"}; // compile correct

So, the best solution is to specify the number of elements of the 2nd
dimension (inner dimension)?


thanks in advance,
George
 
Hello everyone,


I find to initialize two dimentional array in Visual Studio, I have to
specify the number of elements. For example,

Code:
const char foo[][] = {"hello",  "world"}; // compile error
const char goo[][64] = {"hello",  "world"}; // compile correct

So, the best solution is to specify the number of elements of the 2nd
dimension (inner dimension)?

Not the "best" solution but "the" solution; that is, it's required. The
compiler needs that information to know how to lay out and access the
array.
 
How to write the code, Doug? Could you let me know your implementation
please? I want to learn better ideas. :-)


regards,
George

Doug Harrison said:
Hello everyone,


I find to initialize two dimentional array in Visual Studio, I have to
specify the number of elements. For example,

Code:
const char foo[][] = {"hello",  "world"}; // compile error
const char goo[][64] = {"hello",  "world"}; // compile correct

So, the best solution is to specify the number of elements of the 2nd
dimension (inner dimension)?

Not the "best" solution but "the" solution; that is, it's required. The
compiler needs that information to know how to lay out and access the
array.
 
Back
Top