fwrite/fread and dynamic arrays

Hello!

My question is: can I pass dynamic arrays to a fwrite and/or a fread function? Or should I write/read the file one item at the time?

EDIT: the dynamic array which is to be written is a heap-created one (with vet = new int[n])

Thanks
Last edited on
can I pass dynamic arrays to a fwrite and/or a fread function?
Yes, of course. As long as it's an actual array, such as one returned by new[], malloc(), or contained in an std::vector, and not something that pretends to be an array, such as the internal contents of an std::deque, you can pass it.

I'd recommend using the C++ I/O library, though.
Topic archived. No new replies allowed.