On Wednesday, 29 October 2014 at 23:28:07 UTC, Justin Whear wrote:
Part of what readln does is *modify* the slice itself, not just
the
pointed-to
characters. In particular it alters the length member so that
you know
how much
input was actually read. This is also why the rvalue reference
sho
On Wed, 29 Oct 2014 23:10:10 +, dcrepid wrote:
> On Wednesday, 29 October 2014 at 21:19:25 UTC, Peter Alexander wrote:
>> You need to take a slice of the buffer:
>>
>> char[] buf = Input[];
>> readln(buf);
>> // line now in buf
>>
>> The reason for this is because you need to know where the st
lol, if only I could edit my posts. The comment preceding the
readln() call was wrong too. This is what I have now:
// readln(buf) requires a slice *Reference*.
// rvalue references aren't supported by D, so readln(Input[])
fails
err, I meant rvalue *reference* above
On Wednesday, 29 October 2014 at 21:19:25 UTC, Peter Alexander
wrote:
You need to take a slice of the buffer:
char[] buf = Input[];
readln(buf);
// line now in buf
The reason for this is because you need to know where the
string ends. If you just passed in Input, how would you know
how long t
On Wed, 29 Oct 2014 21:14:13 +
dcrepid via Digitalmars-d-learn
wrote:
> Now, I'm used to 'buffer' meaning one thing, but here it seems
> that buffer means something more akin to a 'sink' object, or a
> forced dynamic array type? Is there some way I can avoid dynamic
> allocations?
take a
On Wednesday, 29 October 2014 at 21:14:17 UTC, dcrepid wrote:
I have this simple code:
int main()
{
import std.stdio;
char[4096] Input;
readln(Input);
//readln!(char)(Input); // also fails
return 0;
}
I get these messages during compilation:
test.d(39): Error: template std.s
You need to take a slice of the buffer:
char[] buf = Input[];
readln(buf);
// line now in buf
The reason for this is because you need to know where the string
ends. If you just passed in Input, how would you know how long
the line read was?
I have this simple code:
int main()
{
import std.stdio;
char[4096] Input;
readln(Input);
//readln!(char)(Input); // also fails
return 0;
}
I get these messages during compilation:
test.d(39): Error: template std.stdio.readln cannot deduce
function from
argument types !()(ch