Thread overview
scanf in MemoryStream
May 20, 2006
sailormoontw
May 20, 2006
Carlos Santander
May 20, 2006
Chris Miller
May 20, 2006
Carlos Santander
May 20, 2006
The code is as follows, I assume this code would work in older version of D compiler, but in current version of D compiler, it halts. Is there anything changed in the scanf function of MemoryStream, and how should I fix to code?

Thanks ^_^



private import std.stream;

void main()
{
MemoryStream ms = new MemoryStream("1.23 4.56 7.89 9.01 ");
float a, b, c, d;
ms.scanf("%f %f %f %f", &a, &b, &c, &d);
}


May 20, 2006
sailormoontw escribió:
> The code is as follows, I assume this code would work in older version of D
> compiler, but in current version of D compiler, it halts. Is there anything
> changed in the scanf function of MemoryStream, and how should I fix to code?
> 
> Thanks ^_^
> 
> 
> 
> private import std.stream;
> 
> void main()
> {
> MemoryStream ms = new MemoryStream("1.23 4.56 7.89 9.01 ");
> float a, b, c, d;
> ms.scanf("%f %f %f %f", &a, &b, &c, &d);
> }
> 
> 

Before the scanf, I think you need
ms.position = 0;

-- 
Carlos Santander Bernal
May 20, 2006
On Sat, 20 May 2006 07:21:43 -0400, sailormoontw <sailormoontw_member@pathlink.com> wrote:

> The code is as follows, I assume this code would work in older version of D
> compiler, but in current version of D compiler, it halts. Is there anything
> changed in the scanf function of MemoryStream, and how should I fix to code?
>
> Thanks ^_^
>
> private import std.stream;
>
> void main()
> {
> MemoryStream ms = new MemoryStream("1.23 4.56 7.89 9.01 ");
> float a, b, c, d;
> ms.scanf("%f %f %f %f", &a, &b, &c, &d);
> }
>

hahaha... not laughing at you, but it's a funny side affect:

There is no scanf in Stream or MemoryStream, but it is accessible because std.c.stdio is imported inside Stream, making the stdin scanf available. stdin scanf is waiting for you to type.
May 20, 2006
Chris Miller escribió:
> On Sat, 20 May 2006 07:21:43 -0400, sailormoontw <sailormoontw_member@pathlink.com> wrote:
> 
>> The code is as follows, I assume this code would work in older version of D
>> compiler, but in current version of D compiler, it halts. Is there anything
>> changed in the scanf function of MemoryStream, and how should I fix to code?
>>
>> Thanks ^_^
>>
>> private import std.stream;
>>
>> void main()
>> {
>> MemoryStream ms = new MemoryStream("1.23 4.56 7.89 9.01 ");
>> float a, b, c, d;
>> ms.scanf("%f %f %f %f", &a, &b, &c, &d);
>> }
>>
> 
> hahaha... not laughing at you, but it's a funny side affect:
> 
> There is no scanf in Stream or MemoryStream, but it is accessible because std.c.stdio is imported inside Stream, making the stdin scanf available. stdin scanf is waiting for you to type.

Use ms.readf, then.

-- 
Carlos Santander Bernal