/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/cpp/cpp-506-1005-010/main.cpp
30 строк
961 B
Spirzen
Code migration pack
09 июн 2026, 01:41
09 июн 2026, 01:41
cebc284
Код
Авторство
О чём код?
#include <iostream> #include <filesystem> #include <iomanip> namespace fs = std::filesystem; void printDiskUsage(const fs::path& root) { auto total = fs::space(root).total_bytes; auto free = fs::space(root).free_bytes; auto used = total - free; double percentUsed = (static_cast<double>(used) / total) * 100.0; std::cout << "Диск: " << root << std::endl; std::cout << "Всего: " << total << " байт" << std::endl; std::cout << "Занято: " << used << " байт (" << std::fixed << std::setprecision(2) << percentUsed << "%)" << std::endl; std::cout << "Свободно: " << free << " байт" << std::endl; std::cout << "---------------------------" << std::endl; } int main() { fs::path root("/"); // Для Linux/macOS используйте "/" или конкретный том #ifdef _WIN32 root = "C:\\"; // Для Windows #endif printDiskUsage(root); return 0; }