-
-
Save MrDOS/6ff5e59322dcd7c736ad1bbe210c9a10 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <fcntl.h> | |
#include <err.h> | |
#include <unistd.h> | |
#include <inttypes.h> | |
#define BUF_SIZE (1048576 * 10) | |
int main(int argc, char *argv[]) | |
{ | |
static char char_buf[BUF_SIZE]; | |
static ssize_t buf_size = BUF_SIZE; | |
void *buf = char_buf; | |
char *p; | |
ssize_t len; | |
uint64_t linect; | |
int fd = open("ten.json", O_RDONLY); | |
if (fd < 0) { | |
warn("bad open"); | |
return 1; | |
} | |
while((len = read(fd, buf, buf_size))) { | |
for(p=buf;len--;p++){ | |
if(*p == '\n'){ | |
linect++; | |
} | |
} | |
} | |
printf("%" PRIu64 "\n", linect); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment