D/stdin と readLine と ReadExceptionTop / D / stdin と readLine と ReadExceptionv0.122 while (!stdin.eof()) { char c; stdin.read(c); text ~= c; } 上のようなコードで標準入力からchar[]に読み込もうとすると ReadException が投げられる。 結論、stdin と Streamは同じようには扱えない。 try { while (!stdin.eof()) { char c; stdin.read(c); text ~= c; } } catch (ReadException e) { if (!stdin.eof()) throw e; } readLine() 式の解決法。 |