Trouble casting uintmax_t from filesystem::space() to an int in C++

13 hours ago 3
ARTICLE AD BOX

I am trying to get the total capacity (including reserved space) of my external W drive as an integer. Here is my code:

#include <iostream> #include <filesystem> int main() { auto size = std::filesystem::space("\\\\.\\W:").capacity; std::cout << "\nCAPACITY: " + std::to_string(static_cast<int>(size)); }

This prints "CAPACITY: 625995776". According to Windows and a similar program I wrote in Java, the capacity of my W drive is 1,012,924,416 bytes, not ~626 million. I assume this is a conversion error, but I don't understand how to fix it.

Read Entire Article