User input readline || readf

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Apr 23 11:52:24 PDT 2015


The paste is still there.

readf leaves the \n from pressing enter in stdin, which gets read
by the next function that's accessing it.

I answered a similiar question in another thread:
http://forum.dlang.org/post/jwxfaztgsyzwqpzajqmf@forum.dlang.org

I see two other mistakes in your code as well:
1. I'm pretty sure you want to pass print_human_list and 
add_new_human a reference to the human_list array. Just add "ref" 
before "Human[] human_list".
> void print_human_list(ref Human[] human_list)

2. In D there exists something called switch fallthrough. Just 
add a "break;" after each case and only the matching block will 
be executed.
>case('A'):
>    add_new_human(human_list);
>    break;

Willkommen in der D Community. ;)


More information about the Digitalmars-d-learn mailing list