www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - 'write' crashes without extra window

reply "Joel" <joelcnz gmail.com> writes:
I have a program that runs at Windows 7 login, each time. But it 
had been opening with a command prompt, so I got rid of the 
prompt and now it some times crashes. I've noticed it before, 
using 'write' without the prompt.
Oct 07 2014
next sibling parent "AsmMan" <jckj33 gmail.com> writes:
On Tuesday, 7 October 2014 at 23:41:14 UTC, Joel wrote:
 I have a program that runs at Windows 7 login, each time. But 
 it had been opening with a command prompt, so I got rid of the 
 prompt and now it some times crashes. I've noticed it before, 
 using 'write' without the prompt.
Can you post the code and the error message (from crash) you're getting?
Oct 07 2014
prev sibling parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
On Tuesday, 7 October 2014 at 23:41:14 UTC, Joel wrote:
 it had been opening with a command prompt, so I got rid of the 
 prompt and now it some times crashes.
That's a feature - writing to a non-existent handle fails, so it throws an exception. (The reason you don't notice this in something like C is you prolly don't check printf's return value...) You could just wrap the write function in a try/catch to explicitly ignore the error.
Oct 07 2014
next sibling parent "Joel" <joelcnz gmail.com> writes:
On Wednesday, 8 October 2014 at 03:33:38 UTC, Adam D. Ruppe wrote:
 On Tuesday, 7 October 2014 at 23:41:14 UTC, Joel wrote:
 it had been opening with a command prompt, so I got rid of the 
 prompt and now it some times crashes.
That's a feature - writing to a non-existent handle fails, so it throws an exception. (The reason you don't notice this in something like C is you prolly don't check printf's return value...) You could just wrap the write function in a try/catch to explicitly ignore the error.
Thanks Adam.
Oct 07 2014
prev sibling parent reply "Gary Willoughby" <dev nomad.so> writes:
On Wednesday, 8 October 2014 at 03:33:38 UTC, Adam D. Ruppe wrote:
 You could just wrap the write function in a try/catch to 
 explicitly ignore the error.
Or if the write function is there only for debug purposes you could wrap it in a debug/version block. http://ddili.org/ders/d.en/cond_comp.html
Oct 08 2014
next sibling parent "Sag Academy" <sagacademyjaipur gmail.com> writes:
On Wednesday, 8 October 2014 at 09:17:01 UTC, Gary Willoughby
wrote:
 On Wednesday, 8 October 2014 at 03:33:38 UTC, Adam D. Ruppe 
 wrote:
 You could just wrap the write function in a try/catch to 
 explicitly ignore the error.
Or if the write function is there only for debug purposes you could wrap it in a debug/version block. http://ddili.org/ders/d.en/cond_comp.html
Yeah, exactly man
Oct 08 2014
prev sibling parent "Kagamin" <spam here.lot> writes:
Or open nul device in place of stdout (windows equivalent of 
/dev/null).
Oct 08 2014