Dynamic memory
Binarydepth via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jul 28 09:09:44 PDT 2015
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]);
}
}
And here is the output I get when running the program :
core.exception.RangeError at code.d(8): Range violation
----------------
0x406cfb _Dmain
???:0
0x415fde void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).runAll().void __lambda1()
../../../../src/libphobos/libdruntime/rt/dmain2.d:408
0x41624e void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).tryExec(scope void delegate())
../../../../src/libphobos/libdruntime/rt/dmain2.d:383
0x4164a8 void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).runAll()
../../../../src/libphobos/libdruntime/rt/dmain2.d:408
0x41624e void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).tryExec(scope void delegate())
../../../../src/libphobos/libdruntime/rt/dmain2.d:383
0x4163d5 _d_run_main
../../../../src/libphobos/libdruntime/rt/dmain2.d:416
0x7f51eb84ea3f __libc_start_main
???:0
0x406088 _start
???:0
0xffffffffffffffff ???
???:0
----------------------------------------------------------------------------------
I just want to read and print data depending on user input.
More information about the Digitalmars-d-learn
mailing list