Skip to content

Instantly share code, notes, and snippets.

@Varriount
Forked from anonymous/testreadbuffer.nim
Created April 30, 2014 01:52
Show Gist options
  • Save Varriount/6c20d6f47add09c694ff to your computer and use it in GitHub Desktop.
Save Varriount/6c20d6f47add09c694ff to your computer and use it in GitHub Desktop.
import strutils
const SIZE = 8192
var
rlen = 0
totlen = 0
buf = newStringOfCap(SIZE)
lc = 0
totlines = 0
while true:
rlen = stdin.readBuffer(addr buf, SIZE)
if rlen == 0: break
# does not like the next line.
# how to make it a "string"?
lc = buf.countLines()
echo lc
totlines.inc(lc)
totlen.inc(rlen)
echo totlen
echo lc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment