no print function output do while
Ali Çehreli
acehreli at yahoo.com
Thu Sep 28 20:17:24 UTC 2017
On 09/28/2017 12:18 PM, dark777 wrote:
> On Thursday, 28 September 2017 at 18:46:56 UTC, Ali Çehreli wrote:
>> On 09/28/2017 08:13 AM, dark777 wrote:
>>> no print function output do while
>>>
>>> in my program after entering the data and select the function that
>>> will print on the screen the same is not printing ..
>>>
>>> and if I choose 'q' or 'Q' does the program not close what is happening?
>>> should not it work just like in C ++?
>>>
>>> https://pastebin.com/iiMVPk4x
>>
>> You made a simple logic error. Change the following || to &&:
>>
>> }while(choice != 'q' || choice != 'Q');
>>
>> Ali
>
> I think it should not give this error
>
> good but until now I do not understand why after I enter with data in
> the function add_human
>
> the same is not printed when I choose the 'p' or 'P' option in the case
>
> void print_list(Human[] human_list)
> {
> foreach(human; human_list)
> {
> writefln("\nNome: %s",human.name);
> writefln("Peso: %0.2f",human.peso);
> writefln("Idade: %d\n",human.age);
> }
> }
It's because add_human is appending to its own array. Change it to by-ref:
void add_human(ref Human[] human_list)
Ali
More information about the Digitalmars-d-learn
mailing list