Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main() {
- struct stat file;
- char buf[5000];
- off_t result = 0;
- while (1) {
- char* st = fgets(buf, sizeof(buf), stdin);
- if (st == NULL) {
- break;
- }
- int str_sz = strlen(buf);
- if (buf[str_sz - 1] == '\n') {
- buf[str_sz - 1] = '\0';
- }
- int status = lstat(buf, &file);
- if (status == 0 && S_ISREG(file.st_mode)) {
- result += file.st_size;
- }
- }
- printf("%ld", result);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement