Last active
January 17, 2019 04:17
-
-
Save ryutorion/9757725 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
/*! | |
@param[in] path path of a file | |
@return byte size of a file (return -1 when file cannnot open) | |
*/ | |
int filesize(char const * path) | |
{ | |
std::ifstream fin(path, std::ios::in | std::ios::ate); | |
return fin ? static_cast<int>(fin.tellg()) : -1; | |
} | |
int main() | |
{ | |
std::cout << filesize("filesize.cpp") << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment