Strumienie w C++ mają metodę write, która działa tak samo jak funkcja fwrite.
Jedyną różnicą jest to, że musisz jawnie rzutować adres bufora na typ const char*.
std::ofstream file;
file.open("/tmp/test.bin", std::ios_base::binary | std::ios_base::out);
unsigned long number = 1;
file.write(reinterpret_cast<const char*>(&number), sizeof(number));
file.flush();
file.close();
Jak chcesz to możesz napisać szablon, który sam zadba o przekazanie odpowiedniego rozmiaru na podstawie typu danych.
template <typename T, typename std::enable_if<std::is_fundamental<T>::value, bool>::type = true>
void myWrite(std::ostream &out, const T& value) {
out.write(reinterpret_cast<const char*>(&value), sizeof(value));
}