Skip to content

Instantly share code, notes, and snippets.

View hashimaziz1's full-sized avatar

Hashim Aziz hashimaziz1

View GitHub Profile
@hashimaziz1
hashimaziz1 / iszero-fast.cpp
Created September 21, 2020 19:07 — forked from BobVul/iszero-fast.cpp
Check for nonzero data in a stream, quickly and without output. Answers http://superuser.com/q/559772/117590.
#include <cstdio>
#define BUFFER_SIZE 1024
int main() {
FILE* file = stdin;
char buffer[BUFFER_SIZE];
long long bytes_read = 0;
while (bytes_read = fread(buffer, 1, BUFFER_SIZE, file)) {