digitalmars.D - D program code
- Vincent (25/25) Nov 13 2013 import std.stdio,std.cstream;
- Adam D. Ruppe (10/12) Nov 13 2013 din.getc has something in its buffer already (the newline from
- Jacob Carlborg (5/12) Nov 13 2013 You need to tell your IDE to not close the console when the application
- Dejan Lekic (2/9) Nov 13 2013 Add the following line to the end of your main() function:
- Dicebot (6/6) Nov 13 2013 Changing
- John Colvin (4/29) Nov 13 2013 I see you've got plenty of answers so I'll just add: please ask
- Vincent (3/3) Nov 13 2013 Sorry sir my post is out of place. But thanks anyway next time I
- bachmeier (3/36) Nov 13 2013 This wouldn't happen so often if digitalmars.D.learn appeared at
- Adam D. Ruppe (2/4) Nov 13 2013 amen, it is so far down that sometimes i forget about it!
- Andrei Alexandrescu (3/7) Nov 13 2013 bugzillize and pullrequestize!
- Vladimir Panteleev (3/12) Nov 13 2013 Is it better now?
- Adam D. Ruppe (3/4) Nov 13 2013 rox!
- Andrei Alexandrescu (3/13) Nov 13 2013 Yah. That reminds me - the source tree should be in our github...
- Vladimir Panteleev (6/8) Nov 13 2013 What about the kitchen-sink library it currently depends on?
import std.stdio,std.cstream; void main(string[] args) { int first; int second; write ("First Number : "); readf (" %s", &first); write ("Second Number : "); readf (" %s", &second); int result = first + second; writeln("Result: ", result); din.getc(); } _________________________________ Problem: When I run this code why it is automatically exit when it shows the result. It allows me to input first numbers and second number but when it shows the result it will totally exit and I can't see the output. I use D-IDE as my editor and dmd2 as my compiler.
Nov 13 2013
On Wednesday, 13 November 2013 at 14:36:22 UTC, Vincent wrote:it shows the result it will totally exit and I can't see the output.din.getc has something in its buffer already (the newline from when you hit enter after readf - it uses the number but left the line), so it doesn't have to wait. Simplest fix is to read two lines at the end: writeln("Result: ", result); readln(); // skip past the enter left from second number readln(); // wait for the user to hit enter again to exit (I'm using readln instead of din so you can just use std.stdio alone)
Nov 13 2013
On 2013-11-13 15:36, Vincent wrote:Problem: When I run this code why it is automatically exit when it shows the result. It allows me to input first numbers and second number but when it shows the result it will totally exit and I can't see the output. I use D-IDE as my editor and dmd2 as my compiler.You need to tell your IDE to not close the console when the application exists. -- /Jacob Carlborg
Nov 13 2013
Problem: When I run this code why it is automatically exit when it shows the result. It allows me to input first numbers and second number but when it shows the result it will totally exit and I can't see the output. I use D-IDE as my editor and dmd2 as my compiler.Add the following line to the end of your main() function: stdin.readln();
Nov 13 2013
Changing readf (" %s", &second); to readf (" %s ", &second); is likely to fix it (untested). There is a "\n" symbol left in buffer from last entry (which gets read by `getc`)
Nov 13 2013
On Wednesday, 13 November 2013 at 14:36:22 UTC, Vincent wrote:import std.stdio,std.cstream; void main(string[] args) { int first; int second; write ("First Number : "); readf (" %s", &first); write ("Second Number : "); readf (" %s", &second); int result = first + second; writeln("Result: ", result); din.getc(); } _________________________________ Problem: When I run this code why it is automatically exit when it shows the result. It allows me to input first numbers and second number but when it shows the result it will totally exit and I can't see the output. I use D-IDE as my editor and dmd2 as my compiler.I see you've got plenty of answers so I'll just add: please ask such questions in digitalmars.D.learn http://forum.dlang.org/group/digitalmars.D.learn
Nov 13 2013
Sorry sir my post is out of place. But thanks anyway next time I know now where will I post my topic/questions. Thanks for the help sirs...
Nov 13 2013
On Wednesday, 13 November 2013 at 14:45:52 UTC, John Colvin wrote:On Wednesday, 13 November 2013 at 14:36:22 UTC, Vincent wrote:This wouldn't happen so often if digitalmars.D.learn appeared at the top of the page.import std.stdio,std.cstream; void main(string[] args) { int first; int second; write ("First Number : "); readf (" %s", &first); write ("Second Number : "); readf (" %s", &second); int result = first + second; writeln("Result: ", result); din.getc(); } _________________________________ Problem: When I run this code why it is automatically exit when it shows the result. It allows me to input first numbers and second number but when it shows the result it will totally exit and I can't see the output. I use D-IDE as my editor and dmd2 as my compiler.I see you've got plenty of answers so I'll just add: please ask such questions in digitalmars.D.learn http://forum.dlang.org/group/digitalmars.D.learn
Nov 13 2013
On Wednesday, 13 November 2013 at 18:39:59 UTC, bachmeier wrote:This wouldn't happen so often if digitalmars.D.learn appeared at the top of the page.amen, it is so far down that sometimes i forget about it!
Nov 13 2013
On 11/13/13 10:47 AM, Adam D. Ruppe wrote:On Wednesday, 13 November 2013 at 18:39:59 UTC, bachmeier wrote:bugzillize and pullrequestize! AndreiThis wouldn't happen so often if digitalmars.D.learn appeared at the top of the page.amen, it is so far down that sometimes i forget about it!
Nov 13 2013
On Wednesday, 13 November 2013 at 20:33:05 UTC, Andrei Alexandrescu wrote:On 11/13/13 10:47 AM, Adam D. Ruppe wrote:Is it better now?On Wednesday, 13 November 2013 at 18:39:59 UTC, bachmeier wrote:bugzillize and pullrequestize!This wouldn't happen so often if digitalmars.D.learn appeared at the top of the page.amen, it is so far down that sometimes i forget about it!
Nov 13 2013
On Wednesday, 13 November 2013 at 21:15:32 UTC, Vladimir Panteleev wrote:Is it better now?rox!
Nov 13 2013
On 11/13/13 1:15 PM, Vladimir Panteleev wrote:On Wednesday, 13 November 2013 at 20:33:05 UTC, Andrei Alexandrescu wrote:Yah. That reminds me - the source tree should be in our github... AndreiOn 11/13/13 10:47 AM, Adam D. Ruppe wrote:Is it better now?On Wednesday, 13 November 2013 at 18:39:59 UTC, bachmeier wrote:bugzillize and pullrequestize!This wouldn't happen so often if digitalmars.D.learn appeared at the top of the page.amen, it is so far down that sometimes i forget about it!
Nov 13 2013
On Wednesday, 13 November 2013 at 21:31:51 UTC, Andrei Alexandrescu wrote:Yah. That reminds me - the source tree should be in our github...What about the kitchen-sink library it currently depends on? What I'd love to do is get going with http://wiki.dlang.org/Event_system and port DFeed to it, but I have much less free time than I expected...
Nov 13 2013