two dimensional array initialization

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?R2Vvcmdl?=

    #1

    two dimensional array initialization

    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
  • Doug Harrison [MVP]

    #2
    Re: two dimensional array initialization

    On Fri, 27 Jul 2007 02:40:06 -0700, George
    <George@discuss ions.microsoft. comwrote:
    >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.

    --
    Doug Harrison
    Visual C++ MVP

    Comment

    • =?Utf-8?B?R2Vvcmdl?=

      #3
      Re: two dimensional array initialization

      How to write the code, Doug? Could you let me know your implementation
      please? I want to learn better ideas. :-)


      regards,
      George

      "Doug Harrison [MVP]" wrote:
      On Fri, 27 Jul 2007 02:40:06 -0700, George
      <George@discuss ions.microsoft. comwrote:
      >
      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.
      >
      --
      Doug Harrison
      Visual C++ MVP
      >

      Comment

      Working...