how do you append arrays?

asdf via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Feb 25 04:53:37 PST 2016


I'm trying to make a terminal input preprocessor with 
alias/shortcuts and history.


import std.stdio;

void main() {
     string line;
     string[] history;

     line = readln();
     foreach(int i; 0..100) history = history + [""]; // XXX

     while(!stdin.eof) {
         writeln(line);
         if(line != history[0]) {
             history[1..100] = history[0..99];
             history[0] = line;
         }
         line = readln();
     }
}




More information about the Digitalmars-d-learn mailing list