I have got some help with this topic. but still can't solve it.
I need to output 4 data files for each different value of ka={0, 1, 2, 3};
each output file include 7000 pairs of x,y value.
outputs names shall be like 'output_ka0.out', 'output_ka1.out', 'output_ka2.out', 'output_ka3.out'
I am using for loop. here is my code with someone's help. I don't know how to handle strings. error is pointing to 'ofstream' in function fileoutsetup ().
Please help. thanks so much
You never set the values in x to anything, and since they're initialized to 0 and the values you put in y are the values in x * some_number, there will never be anything but 0s in either array.
Also, line 43 should be: for ( t=0; t<7000; t++) You are currently accessing memory you shouldn't be.
error is pointing to 'ofstream' in function fileoutsetup ()
I'm not sure, but I think the problem may be line 38. ios::trunc and ios::app don't make much sense together. ios::app implies there is data in the file you need to seek past.
Of course, your fileout functions don't make much sense anyway. =P
If it's possible to wait and do all the output after the computations are done, that is probably preferable. file output that includes opening and closing a file in the middle of your main loop isn't really very smart.