3D array in Pascal

Discussion in 'Programmer's Corner' started by lkgan, Jan 19, 2010.

  1. lkgan

    Thread Starter Member

    Dec 18, 2009
    117
    0
    Hi everyone,

    Currently I am using a 3D array variable in Pascal language. Can the types of declaration in each dimensional be different. For eg, a 3D variable was declared as

    Value : array[0..2, 0..3, 0..5] of longint.

    And now I use it as below:

    Value [A, B, C] := number;

    My question is, for eg, can A be declared as int, B declared as int, and C declared as longint? Since the Value array was declared as longint, A, B and C should also ONLY declared as longint? :confused:

    Thanks in advance for answering my question. :)
     
  2. avtanski

    Member

    May 29, 2008
    12
    0
    Actually neither A, B, or C are longint. The longint is the value of the array and it has nothing to do with the types of A, B, and C. For A, B, and C even a shortint would do.

    I hope I understand your question correctly.
     
  3. lkgan

    Thread Starter Member

    Dec 18, 2009
    117
    0
    Thanks for answering, so it means that A, B and C can be a string or any types?
     
  4. avtanski

    Member

    May 29, 2008
    12
    0
    String - no, but shortint, int, and longint should work.
     
  5. kf2qd

    New Member

    Feb 4, 2010
    2
    0
    Been a while since I did any Pascal - but don't you want an array of record (eq. to a struct in C)?
     
  6. lkgan

    Thread Starter Member

    Dec 18, 2009
    117
    0
    I don't quite know how to use a struct in C, can you please give me the example base on my example above?
     
Loading...