hmm the paste is away ?!? here i post my source one more time.

[code]
import std.stdio;
import std.string;

struct Human {
    string name;
    ushort age;
};


void print_human_list(Human[] human_list){
    foreach(human; human_list){
        writeln(human.name);
        writeln(human.age);
    }
    writeln("");
}



void add_new_human(Human[] human_list){
    ushort age;                               //
    write("Name: ");                          //  The Output is
    string name = strip(stdin.readln());      //  Name: Age:
    write("Age: ");                           //  And the Error
readf(" %u", &age); // std.conv.ConvException@/usr/include/dlang/ldc/std/conv.d(1968): Human tmp_human = {name, age}; // Unexpected 's' when converting from type LockingTextReader to type uint
    human_list ~= tmp_human;
}



int main(){
    Human[] human_list;
    char choice;

    for(;;){
        writeln("A)dd New Human.");
        writeln("P)rint Human List.");
        writeln("Q)uit.");
        write(": ");
        readf("%c", &choice);
        switch(choice){
            case('A') : add_new_human(human_list);
            case('P') : print_human_list(human_list);
            case('Q') : return 0;
            default   : continue;
        }
    }
}
[/code]

Reply via email to