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

2015-03-21 Thread Ivan Kazmenko via Digitalmars-d-learn
On Saturday, 21 March 2015 at 14:31:20 UTC, Dennis Ritchie wrote: In C++ it is fully working: char s[25], t[25]; scanf(%s%s, s, t); Indeed. Generate a 10-character string: - import std.range, std.stdio; void main () {'a'.repeat (10).writeln;} - Try to copy it with D

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

2015-03-21 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 21 March 2015 at 15:05:56 UTC, Ivan Kazmenko wrote: On Saturday, 21 March 2015 at 14:31:20 UTC, Dennis Ritchie wrote: In C++ it is fully working: char s[25], t[25]; scanf(%s%s, s, t); Indeed. And why in D copied only the first 32767 characters of the string? I'm more

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

2015-03-21 Thread Dennis Ritchie via Digitalmars-d-learn
In C++ it is fully working: char s[25], t[25]; scanf(%s%s, s, t); http://codeforces.com/contest/527/submission/10376381?locale=en

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

2015-03-21 Thread anonymous via Digitalmars-d-learn
On Saturday, 21 March 2015 at 08:37:59 UTC, Dennis Ritchie wrote: Tell me, please, why this code works correctly always: [...] And this code works correctly is not always: import std.stdio; readf(%s\n, n); char[200010] s, t; scanf(%s%s, s.ptr, t.ptr); Please go into more detail about how

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

2015-03-21 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 21 March 2015 at 12:08:05 UTC, anonymous wrote: Please go into more detail about how it doesn't work. Task: http://codeforces.com/contest/527/problem/B?locale=en It works: char[200010] s, t; s = readln.strip; t = readln.strip;

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

2015-03-21 Thread FG via Digitalmars-d-learn
On 2015-03-21 at 16:05, Ivan Kazmenko wrote: Generate a 10-character string [...] Try to copy it with D scanf and printf: - import std.stdio; void main () { char [10] a; scanf (%s, a.ptr); printf (%s\n, a.ptr); } - Only 32767 first characters of the string are

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

2015-03-21 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 21 March 2015 at 19:09:59 UTC, FG wrote: In what universe?! Which OS, compiler and architecture? On Saturday, 21 March 2015 at 19:09:59 UTC, FG wrote: In what universe?! Which OS, compiler and architecture? Windows 8.1 x64, dmd 2.066.1: import std.range, std.stdio; void main

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

2015-03-21 Thread anonymous via Digitalmars-d-learn
On Saturday, 21 March 2015 at 15:05:56 UTC, Ivan Kazmenko wrote: Generate a 10-character string: - import std.range, std.stdio; void main () {'a'.repeat (10).writeln;} - Try to copy it with D scanf and printf: - import std.stdio; void main () { char [10] a;

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

2015-03-21 Thread FG via Digitalmars-d-learn
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

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

2015-03-21 Thread anonymous via Digitalmars-d-learn
On Saturday, 21 March 2015 at 23:00:46 UTC, Ivan Kazmenko wrote: To me, it looks like a bug somewhere, though I don't get where exactly. Is it in bits of DigitalMars C/C++ compiler code glued into druntime? As far as I understand, the bug is in snn.lib's scanf. snn.lib is Digital Mars's

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

2015-03-21 Thread Ivan Kazmenko via Digitalmars-d-learn
On Saturday, 21 March 2015 at 16:34:44 UTC, Dennis Ritchie wrote: And why in D copied only the first 32767 characters of the string? I'm more days couldn't understand what was going on... To me, it looks like a bug somewhere, though I don't get where exactly. Is it in bits of DigitalMars

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

2015-03-21 Thread FG via Digitalmars-d-learn
On 2015-03-21 at 22:15, FG wrote: 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

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

2015-03-21 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 21 March 2015 at 23:00:46 UTC, Ivan Kazmenko wrote: On Saturday, 21 March 2015 at 16:34:44 UTC, Dennis Ritchie wrote: And why in D copied only the first 32767 characters of the string? I'm more days couldn't understand what was going on... To me, it looks like a bug somewhere,