The difference in string and char[], readf() and scanf()

FG via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Mar 21 14:15:04 PDT 2015


On 2015-03-21 at 21:02, Dennis Ritchie wrote:
>> In what universe?! Which OS, compiler and architecture?
> Windows 8.1 x64, dmd 2.066.1:

That's strange. I cannot recreate the problem on Win7 x64 with dmd 2.066.1, neither when compiled for 32- nor 64-bit. I have saved the a's to a file and use input redirect to load it, while the program is as follows:

import std.stdio;
void main () {
     char [100000] a;
     scanf ("%s", a.ptr);
     printf ("%s\n", a.ptr);
}


>       freopen("in.txt", "r", din.file);

No, that approach didn't change the result. I still get 10000.


More information about the Digitalmars-d-learn mailing list