Write to file problem (awkward output)

EDIT: Ahh seems the problem was on behalf of Notepad. I opened the file with wordpad and it's fine. Thanks :s

Hi,

I've stumbled upon a problem I haven't seen before just thought I'd post the problem see if anyone else has experienced a similar issue.

The program does some calculations and ouputs 2 values (x,y-value) for each temperature. I run the program from T=300 to 1000, the output is fine, I run it for T=20 to 500 or so and it's fine but when I run it from T=20 to 1000 it outputs some awkward symbols resembling the japanese language. So in order to plot the output I need to run it from T=20 to 300 and seperately from 300 to 1000, so I need to run it twice. The output is in to a .txt file.

Great if anyone can help out. Cheers

K


The output part of the program:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
ofstream myfile;
	myfile.open("a.txt");
	myfile << "y:=[";
	for(int i = 0; i < step - 1; i++){
		myfile << "[" << x1[i] << "," << T[i]-273.15 << "]" << "," << "[" << x2[i] << "," << T[i]-273.15 << "],";
	}
	myfile << "[" << x1[step - 1] << "," << T[step - 1]-273.15 << "]" << "," << "[" << x2[step - 1] << "," << T[step - 1]-273.15 << "]]:"
		<< "plot(y,style = point);";
	myfile.close();
	

	t2 = clock();
	dif = (double)(t2 - t1)/CLOCKS_PER_SEC;
	cout << "\nNo. of seconds = " << dif << endl;
	cin.ignore(255,'\n');
	return 0;


Part of the a.txt output
 
㩹嬽㉛㌮㄰ㄹⵥ〰ⰶ〲ⱝせ㌮㔵㘲ⰸ〲ⱝ㉛㐮〰㈵ⵥ〰ⰶㄲⱝせ㌮㐵㌸ⰷㄲⱝ㉛㔮㈰㘵ⵥ〰ⰶ㈲ⱝせ㌮㐵〴ⰵ㈲ⱝ㉛㘮㠰㠱ⵥ〰ⰶ㌲ⱝせ㌮㌵㜹ⰳ㌲ⱝ㉛㜮㜱㔴ⵥ〰ⰶ㐲ⱝせ㌮㌵㐵ⰱ㐲ⱝ㉛㠮〳㘴ⵥ〰ⰶ㔲ⱝせ㌮㌵〱ⰹ㔲ⱝ㉛㤮㜴㌳ⵥ〰ⰶ㘲ⱝ
Last edited on
Looks like Notepad was incorrectly auto-detecting the file as UTF16.

So yeah. It's a notepad problem, not a problem with your program.

I recommend you get Notepad++ anyway ;D
Thanks for the info :)
Topic archived. No new replies allowed.