On Tuesday, 28 July 2015 at 16:09:46 UTC, Binarydepth wrote:
Here is what I'm trying to do :

import std.stdio : readf, writef;
void main()     {
        int[2][] nam;
        int num;
        readf(" %d", &num);
        nam.length = num;
        foreach(nim; 0..num)    {
                readf(" %d %d", &nam[0][num], &nam[1][num]);
        }
        foreach(nim; 0..num)    {
                writef(" %d %d\n", &nam[0][num], &nam[1][num]);
        }
}


In addition to Adam:
there are typos (num instead of nim) - since num is the array length and the indices are 0-based, num is out of bounds...

        foreach(nim; 0..num)    {
                readf(" %d %d", &nam[nim][0], &nam[nim][1]);
        }
        foreach(nim; 0..num)    {
                writef(" %d %d\n", nam[nim][0], nam[nim][1]);
        }
works fine.

  • Dynamic memory Binarydepth via Digitalmars-d-learn
    • Re: Dynamic memory Adam D. Ruppe via Digitalmars-d-learn
      • Re: Dynamic memory Binarydepth via Digitalmars-d-learn
        • Re: Dynamic memo... Adam D. Ruppe via Digitalmars-d-learn
          • Re: Dynamic ... Binarydepth via Digitalmars-d-learn
            • Re: Dyn... Adam D. Ruppe via Digitalmars-d-learn
              • Re:... Binarydepth via Digitalmars-d-learn
            • Re: Dyn... anonymous via Digitalmars-d-learn
              • Re:... Binarydepth via Digitalmars-d-learn
              • Re:... Binarydepth via Digitalmars-d-learn
                • ... anonymous via Digitalmars-d-learn
                • ... Binarydepth via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn
                • ... Binarydepth via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn
                • ... Binarydepth via Digitalmars-d-learn
                • ... anonymous via Digitalmars-d-learn
                • ... Binarydepth via Digitalmars-d-learn

Reply via email to