www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Struct List Human

reply dark777 <jeanzonta777 yahoo.com.br> writes:
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?
Sep 24 2017
next sibling parent reply Suliman <evermind live.ru> writes:
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
Sep 24 2017
parent reply dark777 <jeanzonta777 yahoo.com.br> writes:
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.
Sep 24 2017
parent reply dark777 <jeanzonta777 yahoo.com.br> writes:
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.
Sep 24 2017
parent reply Neia Neutuladh <neia ikeran.org> writes:
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?
Sep 24 2017
parent dark777 <jeanzonta777 yahoo.com.br> writes:
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 ...
Sep 24 2017
prev sibling parent reply Adam D. Ruppe <destructionator gmail.com> writes:
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
Sep 24 2017
parent dark777 <jeanzonta777 yahoo.com.br> writes:
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
Sep 24 2017