writing a matrix into a txt file with ; after each row C++?

I have a matrix " PowerMatrix" which is of size 24 * 24 now i need to know how can i write this matrix into a text file with a ; after each row? how can i do this? i have this code up till now but it's not working i don't know why and yet i can't separate using a ; after each row?

std::ofstream output("Power vector.txt"); 
for (k=1; k<PowerMatrix.size(); k++)
{
for (l=1; l<PowerMatrix.size(); l++)
{
output << PowerMatrix[i][j] << " "; // behaves like cout - cout is also a stream
}
output << "\n";
} 

Answers


Just add a ; before the newline:

std::ofstream output("Power vector.txt"); 
for (k=1; k<PowerMatrix.size(); k++)
{
    for (l=1; l<PowerMatrix.size(); l++)
    {
        output << PowerMatrix[i][j] << " "; // behaves like cout - cout is also a stream
    }
    output << ";" << endl;
} 

Need Your Help

Closures in JavaScript

javascript jquery closures

I have a code like this where I am trying to add an event handler to some button. I would like to use a global variable &amp; store its current value in callback closure &amp; not its reference.