Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main() {
- const char* filename = "matrix.backup";
- int row = 3, col = 3;
- int* matrix = new int [row*col];
- for(int i = 0; i < row; ++i) {
- for(int j = 0; j < col; ++j) {
- matrix[i*col + j] = i*col + j;
- }
- }
- ofstream output_file_stream;
- output_file_stream.open(filename);
- for(int i = 0; i < row; ++i) {
- for(int j = 0; j < col; ++j) {
- output_file_stream << matrix[i*col + j] << " ";
- }
- output_file_stream << endl;
- }
- delete [] matrix;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement