Please describe what is the problem, otherwise I might be answering the wrong question.
I see a couple of problems now:
when you write a text file, you should open the file for writing text. Otherwise the linefeeds will not be expanded correctly (it will automatically change simple "\n" to "\r\n" under windows, which is the proper indication of line feed under windows). ile=fopen("inputmatriks.txt","wt"); // notice "wt" instead of "w"
The second thing is - you might want to put spaces between matrix elements: fprintf (file, "%d ",data[i][j]); // notice space after %d
Also it is a bit weird that you mix the usage of c++ streams with FILE*. Why don't you use std::ofstream instead of FILE*? By the way, standard streams are open for handling text input/output by default.
This is not an error - this is a warning. And to be honest, a weird one (my compiler doesn't give any warnings).
Equivalent of your code using std::ofstream:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <fstream>
...
// open the file (for writing because it is an ofstream, meaning "output file stream")
std::ofstream output("inputmatriks.txt");
for (i=0;i<M;i++)
{
for (j=0;j<M;j++)
{
output << data[i][j] << " "; // behaves like cout - cout is also a stream
}
output << "\n";
}
// no need to close the file explicitly because it will be closed automatically by destructor of ofstream.
// However you can do that if you like using output.close()
Edit: Oh, and by the problem I meant not the task you are trying to solve, but explanation of what is going wrong. For example, "there is a compilation error (post the error)", or "I cannot find the output file", or "the ouput file is empty/it's contents are unexpected".