Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. #include <inttypes.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. int main()
  6. {
  7.     char file_name[PATH_MAX];
  8.     uint64_t result = 0;
  9.     struct stat t;
  10.     char* nl;
  11.     while( fgets(file_name, sizeof(file_name)), stdin ) {
  12.         nl = memchr(file_name, '\n', sizeof(file_name));
  13.         if (nl) {
  14.             *nl = '\0';
  15.         }
  16.         if (-1 != lstat(file_name, &st)) {
  17.             if (S_ISREG(st.st_mode)) {
  18.                 result += st.st_size;
  19.             }
  20.         }
  21.     }
  22.     printf("%"PRIu64"\n", result);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement