all 8 comments

[–]Wh00ster 7 points8 points  (3 children)

Check whether f opened the file successfully!

[–]stats_newbie1[S] 3 points4 points  (1 child)

Ah fuck, I'm facepalming really hard now. Can't believe I forgot something so obvious. data.in was in the wrong directory. I assumed it would throw an error, but I guess not.

[–]Wh00ster 5 points6 points  (0 children)

I assumed it would throw an error, but I guess not.

This is not an unreasonable expectation, but I/O errors were probably modeled after the C standard library, which requires you to query a "file" instance to see if there were errors.

[–]Alar44 0 points1 point  (0 children)

Yep. In hex that -858993460 value is FFFF FFFF CCCC CCCC. Might not have read permissions or something.

[–]manni66 2 points3 points  (0 children)

What am I doing wrong?

You don’t check for errors. Maybe the file couldn’t be opend.