Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <fcntl.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <sys/stat.h>
  5. #include <sys/types.h>
  6. #include <unistd.h>
  7.  
  8. int main()
  9. {
  10. char name[1000];
  11. long long ans = 0;
  12. struct stat st;
  13. char* nl;
  14. while (fgets(name, sizeof(name), stdin)) {
  15. nl = memchr(name, '\n', sizeof(name));
  16. if (nl) {
  17. *nl = '\0';
  18. }
  19. if (-1 != lstat(name, &st) && S_ISREG(st.st_mode)) {
  20. ans += st.st_size;
  21. }
  22. }
  23. printf("%lld", ans);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement