loadBytes()

Input / Files

Description

Reads the contents of a file into a vector of bytes.

Syntax

std::vector<unsigned char> loadBytes(std::string path)

Parameters

NameTypeDescription
pathstd::stringpath to the file

Returns

std::vector

Related

Under the Hood

From Processing.h:

inline std::vector<unsigned char> loadBytes(const std::string& path) { std::ifstream f(path,std::ios::binary); return std::vector<unsigned char>((std::istreambuf_iterator<char>(f)),std::istreambuf_iterator<char>()); } static std::vector<unsigned char> loadBytes(const std::string& path);

Under the Hood

From Processing.cpp:

std::vector<unsigned char> PApplet::loadBytes(const std::string& path) { std::ifstream f(path, std::ios::binary); return std::vector<unsigned char>((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>()); }