reading from file
Ali via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Dec 13 13:13:26 PST 2016
On Tuesday, 13 December 2016 at 16:59:17 UTC, Namal wrote:
> On Tuesday, 13 December 2016 at 16:57:40 UTC, Namal wrote:
>> Sorry if I wasn't clear. The array should be two demensional
>> and each line in text line should be a row in that 2x2 array.
>
> Also, it should be saved as an integer.
And extending Ali's solution you can actually get the data in to
a two dimentional array at compile time and have it in static
memory with a small adjustment:
static immutable matrix = import("data.txt")
.split("\n")
.map!(a => a.split(",").map!(to!int).array)
.array;
void main() {
writeln(matrix);
}
More information about the Digitalmars-d-learn
mailing list