Closed SamAxe closed 3 years ago
For puzzle 25000
cat puzzle.pcap|./pcat | awk '(NR > 3) { print $6; }' | grep -v "^0000000000$" | while read line; do echo $line | ./unhex ; done
feof
vs EOF
I don't think it matters. getchar
explicitly returns EOF on EOF.
On one hand, testing for EOF
or running feof()
right after getchar
is best practice, and you advance the counter before the switch.
On the other hand, within this scope, you only use count
var on one of the switch cases; the return
exits the scope.
@SamAxe's example doesn't blow up for me.
Another point, testing an integer equality against a macro is cheaper than executing a function call.
Probably something weird in my environment or shell. I'd just close the PR at this point.
feof
and an EOF
return value aren't equivalent. EOF
can also be returned if there is an error that can be checked with ferror
.
Right, so anything removing the EOF check ought to also check ferror
so we don't start trying to process garbage data...
No idea if this behavior is intended or just a hassle.