fork(1) download
  1. #include <fstream>
  2. #include <iostream>
  3. #include <string>
  4.  
  5. void printSize(const std::string& address) {
  6. std::fstream motd(address.c_str(), std::ios::binary|std::ios::in|std::ios::ate);
  7. if(motd) {
  8. std::fstream::pos_type size = motd.tellg();
  9. std::cout << address << " " << size << "\n";
  10. } else {
  11. perror(address.c_str());
  12. }
  13. }
  14.  
  15. int main () {
  16. printSize("/etc/motd");
  17. printSize("/etc/passwd");
  18. }
  19.  
Success #stdin #stdout 0.01s 2860KB
stdin
Standard input is empty
stdout
/etc/passwd 3188995