saveBytes()

Output / Files

Description

Writes a vector of bytes to a file.

Syntax

bool saveBytes(std::string path, std::vector<unsigned char> data)

Parameters

NameTypeDescription
pathstd::stringpath to write to
datastd::vectorbytes to write

Returns

bool

Related

Under the Hood

From Processing.h:

inline bool saveBytes(const std::string& path, const std::vector<unsigned char>& data) { std::ofstream f(path,std::ios::binary); if (!f) return false; f.write(reinterpret_cast<const char*>(data.data()),data.size()); return true; } inline bool saveStream(const std::string& path, const std::vector<unsigned char>& data) { return saveBytes(path,data); static bool saveBytes(const std::string& path, const std::vector<unsigned char>& d);

Under the Hood

From Processing.cpp:

bool PApplet::saveBytes(const std::string& path, const std::vector<unsigned char>& data) { std::ofstream f(path, std::ios::binary); if (!f) return false; f.write(reinterpret_cast<const char*>(data.data()), data.size()); return true; }