two dimensional array initialization

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
 
D

Doug Harrison [MVP]

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.
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top