Bug 13486 – Streams fail

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2014-09-16T21:05:00Z
Last change time
2015-06-09T01:31:16Z
Assigned to
nobody
Creator
najamkhn

Attachments

IDFilenameSummaryContent-TypeSize
1429streamfail.dFull code with compilation instruction and expeced output descriptiontext/x-dsrc585

Comments

Comment #0 by najamkhn — 2014-09-16T21:05:05Z
Created attachment 1429 Full code with compilation instruction and expeced output description Trying to get the streams to work and skip the first line but using the stdin insists on reading the first line, is it normal? seems to me that the cursor isn't getting updated after readf reads the first input? /* Compiling it the following way: dmd streamfail.d ./streamfail < input.txt Contents of `input.txt` 9 11 2 3 4 5 6 7 8 9 10 Expected Output: [11, 2] [3, 4] [5, 6] [7, 8] [9, 10] Current Output: [] [11, 2] [3, 4] [5, 6] [7, 8] [9, 10] */ import std.stdio; import std.array; import std.conv; int main() { int num, x, y; readf("%d", &num); foreach (string line; lines(stdin)) { auto coords = to!(double[])(split(line)); writeln(coords); } return true; }
Comment #1 by dlang-bugzilla — 2014-09-21T02:14:51Z
> readf("%d", &num); You have indicated that you do not want to skip past the whitespace after the first number. Instead, try: readf("%d\n", &num); If you are not sure whether something is a D bug, you will get a faster reply on the learn group: http://forum.dlang.org/group/digitalmars.D.learn