Is there a way to format the numbers in output file?

I made a program which outputs certain number to an external file. To display the output inside the program I would simply use codes like "setw" and setprecision but I couldn't format my numbers in output file with these codes. Am I missing something?Or is there any trick to do it?

n can be upto 999.

for (int k=0; k<n, k++)
for (int l=0; l<n; l++)
sqrfile<<setw(4)<<box[k][l];
sqrfile<<endl;

That should work. What does the contents of the output file look like, and how do you want it to look?

When you say "n can be upto 999", do you mean box[k][l] can be up to 999? If not, what sort of values are there.
Topic archived. No new replies allowed.