ppm file to buffer

How can i save a ppm file into a buffer byte by byte?
1
2
3
4
5
6
7
8
9
10
11
std::string load_ppm(std::string filename) {
    std::ifstream handle(filename);
    std::string contents;
    char byte; // the char datatype is guaranteed to be 1 byte.

    while(handle >> byte) {
        contents += byte;
    }

    return contents;
}
Last edited on
Topic archived. No new replies allowed.