MCPcopy Create free account
hub / github.com/ShivaBhattacharjee/KeyZen / read_file

Function read_file

data/cpp/06_error_handling.cpp:6–15  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4#include <string>
5
6std::string read_file(const std::string& path) {
7 std::ifstream f(path);
8 if (!f) {
9 throw std::runtime_error("cannot open: " + path);
10 }
11 return std::string(
12 std::istreambuf_iterator<char>(f),
13 std::istreambuf_iterator<char>()
14 );
15}
16
17int safe_divide(int a, int b) {
18 if (b == 0) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected