Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
September 24, 2017 Struct List Human | ||||
---|---|---|---|---|
| ||||
I have the following code: https://pastebin.com/PWuaXJNp but typing my name does not go to the next line as soon as I press enter how to solve this? |
September 24, 2017 Re: Struct List Human | ||||
---|---|---|---|---|
| ||||
Posted in reply to dark777 | On Sunday, 24 September 2017 at 14:32:14 UTC, dark777 wrote:
> I have the following code:
> https://pastebin.com/PWuaXJNp
> but typing my name does not go to the next line as soon as I press enter
> how to solve this?
use writeln instead write
|
September 24, 2017 Re: Struct List Human | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On Sunday, 24 September 2017 at 15:22:30 UTC, Suliman wrote:
> On Sunday, 24 September 2017 at 14:32:14 UTC, dark777 wrote:
>> I have the following code:
>> https://pastebin.com/PWuaXJNp
>> but typing my name does not go to the next line as soon as I press enter
>> how to solve this?
>
> use writeln instead write
nothing to see hand
when you execute and call
Name:
I type my name:
Name: dark777 + [enter]
and he does not jump to the next line to get the age
This is what I want to know how to solve.
|
September 24, 2017 Re: Struct List Human | ||||
---|---|---|---|---|
| ||||
Posted in reply to dark777 | On Sunday, 24 September 2017 at 15:51:01 UTC, dark777 wrote:
> On Sunday, 24 September 2017 at 15:22:30 UTC, Suliman wrote:
>> On Sunday, 24 September 2017 at 14:32:14 UTC, dark777 wrote:
>>> I have the following code:
>>> https://pastebin.com/PWuaXJNp
>>> but typing my name does not go to the next line as soon as I press enter
>>> how to solve this?
>>
>> use writeln instead write
>
> nothing to see hand
>
> when you execute and call
> Name:
>
> I type my name:
> Name: dark777 + [enter]
>
> and he does not jump to the next line to get the age
> This is what I want to know how to solve.
nothing to see hand
when you execute and call
Name:
I type my name:
Name: dark777 + [enter]
and he does not jump to the next line to get the age
This is what I want to know how to solve.
|
September 24, 2017 Re: Struct List Human | ||||
---|---|---|---|---|
| ||||
Posted in reply to dark777 | On Sunday, 24 September 2017 at 16:13:30 UTC, dark777 wrote:
> when you execute and call
> Name:
>
> I type my name:
> Name: dark777 + [enter]
>
> and he does not jump to the next line to get the age
> This is what I want to know how to solve.
Add a `writeln();` after reading input, maybe?
|
September 24, 2017 Re: Struct List Human | ||||
---|---|---|---|---|
| ||||
Posted in reply to dark777 | I think readf("%s") reads everything available. readf(" %s\n") might help but personally, I say avoid readf. Just use readln and to!int instead auto line = readln(); if(line.length == 0) writeln("please enter a number"); age = to!int(line); to is from import std.conv |
September 24, 2017 Re: Struct List Human | ||||
---|---|---|---|---|
| ||||
Posted in reply to Neia Neutuladh | On Sunday, 24 September 2017 at 17:05:11 UTC, Neia Neutuladh wrote:
> On Sunday, 24 September 2017 at 16:13:30 UTC, dark777 wrote:
>> when you execute and call
>> Name:
>>
>> I type my name:
>> Name: dark777 + [enter]
>>
>> and he does not jump to the next line to get the age
>> This is what I want to know how to solve.
>
> Add a `writeln();` after reading input, maybe?
I changed the write by writeln and it still did not work, I added it after receiving the first entry and it did not work ...
|
September 24, 2017 Re: Struct List Human | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Sunday, 24 September 2017 at 18:00:32 UTC, Adam D. Ruppe wrote:
> I think readf("%s") reads everything available. readf(" %s\n") might help but personally, I say avoid readf.
>
> Just use readln and to!int instead
>
>
> auto line = readln();
> if(line.length == 0)
> writeln("please enter a number");
>
> age = to!int(line);
>
>
> to is from import std.conv
I added \n and it worked.
I created a float variable and wanted to know how to read or print the same?
reading?
write ("Weight:");
readf (" %ld\n", &peso);
and
writefln ("Weight:% ld", human.peso);
but he returned me errors
|
Copyright © 1999-2021 by the D Language Foundation