Thread overview | ||||||
---|---|---|---|---|---|---|
|
May 20, 2006 scanf in MemoryStream | ||||
---|---|---|---|---|
| ||||
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 Re: scanf in MemoryStream | ||||
---|---|---|---|---|
| ||||
Posted in reply to sailormoontw | 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 Re: scanf in MemoryStream | ||||
---|---|---|---|---|
| ||||
Posted in reply to sailormoontw | 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 Re: scanf in MemoryStream | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris Miller | 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 |
Copyright © 1999-2021 by the D Language Foundation