Writing Array to outputfile

Hi, i'm trying to write a array to a txt file and my program works perfect, but when i open the file it saved to it's a bunch of "0"'s, how do i get them to represent the values?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
void convert_celsius(const int nums[], int index)
{
	ofstream outputFile;
	outputFile.open ("celsius.txt");
	int new_array [index];

	for(int e = 0; e < index; e++)
	{
		new_array[e] = (nums[e] - 32) * (5/9);
		outputFile << new_array[e]<< " ";
	}

	outputFile.close();

	cout<<"You're temperatures have been converted from ";
	cout <<"Fahrenheit to Celsius." << endl;
	cout<<"The new values have been saved to file celsius.txt." << endl;
	
}
1
2
new_array[e] = (nums[e] - 32) * (5/9);
// 5/9 = 0 since you're dividing two integers, which gives an integer result 

Do you see your problem now?
Last edited on
Yes i do! Thanks a lot
Topic archived. No new replies allowed.