saving arrays into a file. How?

Anyone out there who can provide me with an example of a program that can save including the necessary includes to include. ty
Something like this should work (It's not tested)
1
2
3
4
5
6
7
8
9
#include <fstream>

int main() {
  int array[] = { 1, 2, 3 };
  std::ofstream os("output.txt");
  for (int i = 0; i < 3; i++) {
    os << array[i];
  }
}
Last edited on
thankyou ropez I will try
Topic archived. No new replies allowed.