Re: how stdin stream works?

2020-08-23 Thread Flade via Digitalmars-d-learn
On Thursday, 20 August 2020 at 19:13:31 UTC, Ali Çehreli wrote: On 8/19/20 11:46 AM, Flade wrote: [...] In some cases clearerr() and readln() may be what is needed: import std.stdio; void main() { int x; bool accepted = false; while (!accepted) { try { write("x: ");

Re: how stdin stream works?

2020-08-23 Thread Flade via Digitalmars-d-learn
On Thursday, 20 August 2020 at 19:13:31 UTC, Ali Çehreli wrote: On 8/19/20 11:46 AM, Flade wrote: [...] Thanks Steve! I will get the input a string then as you said and then I'll try to convert it! Thanks a lot, have a nice day! In some cases clearerr() and readln() may be what is needed:

Re: how stdin stream works?

2020-08-19 Thread Flade via Digitalmars-d-learn
On Wednesday, 19 August 2020 at 18:11:23 UTC, Steven Schveighoffer wrote: On 8/19/20 1:44 PM, Flade wrote: Hi everyone! I'm trying to do error handling (with the try block) and when I give a wrong value to the variable (it is an integer and I give a non-number value), then It doesn't let me

how stdin stream works?

2020-08-19 Thread Flade via Digitalmars-d-learn
Hi everyone! I'm trying to do error handling (with the try block) and when I give a wrong value to the variable (it is an integer and I give a non-number value), then It doesn't let me re get input. The code: int x; bool not_accepted = false; while (!not_accepted) { try {

can't access an alias created inside an if statement

2020-08-05 Thread Flade via Digitalmars-d-learn
I have used an if-else statement to create an alias to avoid code duplication but it doesn't let me access it outside the if statement. Is there a way to solve this?

Re: can't access an alias created inside an if statement

2020-08-05 Thread Flade via Digitalmars-d-learn
On Wednesday, 5 August 2020 at 09:25:23 UTC, Simen Kjærås wrote: On Wednesday, 5 August 2020 at 09:05:36 UTC, Flade wrote: I have used an if-else statement to create an alias to avoid code duplication but it doesn't let me access it outside the if statement. Is there a way to solve this?

Re: can't access an alias created inside an if statement

2020-08-05 Thread Flade via Digitalmars-d-learn
On Wednesday, 5 August 2020 at 09:39:47 UTC, Simen Kjærås wrote: On Wednesday, 5 August 2020 at 09:32:58 UTC, Flade wrote: Thanks! You see it should work but the thing is. I'm using it inside a function. I'm checking for one of the function's parameter (if parameter == false) and it says that