digitalmars.D - scanf in MemoryStream
- sailormoontw (11/11) May 20 2006 The code is as follows, I assume this code would work in older version o...
- Carlos Santander (5/23) May 20 2006 Before the scanf, I think you need
- Chris Miller (6/20) May 20 2006 hahaha... not laughing at you, but it's a funny side affect:
- Carlos Santander (4/31) May 20 2006 Use ms.readf, then.
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:Use ms.readf, then. -- Carlos Santander BernalThe 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