April 16, 2014 Re: Scanf function changes value of in-loop variable | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Wednesday, 16 April 2014 at 18:46:18 UTC, Ali Çehreli wrote:
> On 04/16/2014 11:36 AM, FreeSlave wrote:
>> Note that readf is not equivalent to scanf since readf does not skip
>> spaces and newline character. Input must completely match format.
>
> Just like in scanf, a single space character is sufficient to consume zero or more whitespace characters.
>
> Ali
My mistake. I thought spaces are counted precisely (or maybe it's old behavior). But you still should add \n at the end of format to avoid format exceptions. That does not make sense for console input since every input ended with Enter, which makes newline anyway.
|
April 16, 2014 Re: Scanf function changes value of in-loop variable | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | It also throws if you input initial or trailing spaces and there are no spaces at the start or end of format string (scanf skips these spaces) |
Copyright © 1999-2021 by the D Language Foundation