hello guys,
i'm facing a difficulty in creating a matrix in pascal, the compiler keeps posting the messeges illegal qualifier at the line 28,7 where i wrote read(M[i,j]), and telling types mismatch coz i declared M is from type Matrice that i defined and then in the procedure Lect2d i declared it an array of longint but i did this bcoz i can't declare it as Matrice because when i'll use in other programmes whee Matrice is an "unknown" type it won't work, here's the code, PLEASE help what to do??

program test_lect2d;

uses crt;
const Max1=2000000000;
             Max2=2000000000;
type  Matrice= array of [1..Max1,1..Max2] of longint;
var   M:Matrice;
            T1,T2: longint;

procedure lect2d(var M: array of longint; Var T1,var T2: longint);

{****************************************************************************}

{cette pocedure lit un tableau a deux dimension dont les elements sont
                              des entiers }

{****************************************************************************}

var i,j: longint;
Begin
writeln('donnez les dimentions de votre matrice');
readln(T1);
readln(T2);
for i := 1 to T1 do
    for j :=1 to T2 do
       begin
       writeln('M[',i,',',j,']=');
       read(M[i,j]);
       end;
end;

BEGIN
lect2d(M,T1,T2);
readln;
END.

Recommended Answers

All 2 Replies

I'm not sure how any of that compiled. Here's what I was able to do in FreePascal.
Disclaimer: I am not a Pascal programmer, but Google and basic knowledge of imperative languages are helpful.

program test_lect2d;
uses crt;
const Max1=4096;
         Max2=4096;
type  Matrice= array [1..Max1,1..Max2] of longint;
var   MyMatrix:Matrice;
        T1,T2: longint;

procedure lect2d(var M: Matrice; Var T1,T2: longint);
{****************************************************************************}
{cette pocedure lit un tableau a deux dimension dont les elements sont
                          des entiers }
{****************************************************************************}
var i,j: longint;
Begin
    writeln('donnez les dimentions de votre matrice');
    readln(T1);
    readln(T2);
    for i := 1 to T1 do
    for j :=1 to T2 do
       begin
           writeln('M[',i,',',j,']=');
           read(M[i,j]);
       end;
end;
BEGIN
    lect2d(MyMatrix,T1,T2);
    readln;
END.

Are you trying to map the whole world in one matrix?
2000000000x2000000000 = 4x10^18.

commented: "I've got the whole world in my ..." page fault. +11
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.