35657

Untitled

Aug 24th, 2024
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2.  
  3. #include <iostream>
  4. #include <string>
  5. #include <fstream>
  6. #include <filesystem>
  7. #include <windows.h>
  8.  
  9. using namespace std;
  10.  
  11. void print_directory(const string& str) {
  12.     for (const auto& a : filesystem::directory_iterator(str)) {
  13.         string name = a.path().filename().string();
  14.         cout << setw(30) << name;
  15.         string full_name = str + '/' + name;
  16.         if (filesystem::is_regular_file(full_name)) {
  17.             cout << '\t' << filesystem::file_size(full_name) << " bute";
  18.         }
  19.         cout << endl;
  20.     }
  21. }
  22.  
  23.  
  24. int main() {
  25.  
  26.     SetConsoleCP(1251); // установка кодировки 1251 в поток ввода
  27.     SetConsoleOutputCP(1251); // установка кодировки 1251 в поток вывода
  28.  
  29.     print_directory("C:/Users/PC/Desktop");
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment