Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static std::vector<std::string> read_stat_file(const std::string &fn) {
- /*
- * Returns list of strings by space delimiter.
- */
- std::vector<std::string> s_buffer;
- {
- std::ifstream stat(fn);
- for (std::string token; std::getline(stat, token, ' ');) {
- s_buffer.push_back(token);
- }
- stat.close();
- }
- return s_buffer;
- }
- auto s_buffer = read_stat_file("/proc/self/stat");
- ...
- //Failed to check s_buffer length
- ...
- auto new_user_time = std::stoull(s_buffer[13]); //Crash
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement