Почему я получаю целое число, а не двойное значение, если начальное значение равно двойному? [дубликат]C++

Программы на C++. Форум разработчиков
Anonymous
Почему я получаю целое число, а не двойное значение, если начальное значение равно двойному? [дубликат]

Сообщение Anonymous »


I am wondering if anyone could help me understand why I am getting an int here and not a double? My guess is it probably due to the fact the decimal part is just .00 but how can I make sure it writes it anyway. Thanks!

#include #include #include using namespace std; int main() { // initalize variables string dataLine; string stationName; string substringMaxTemp; string substringLowTemp; int positionMaxTemp; int positionLowTemp; double maxTemp = 0.0; double minTemp = 99.9; int positionStationName = 0; ifstream inputFile; // open the input file (program expects the file to be in the same directory // as the program) inputFile.open("reduced_columns(2).txt"); // check if the file is successfully opened if (!inputFile) { cout

Источник: https://stackoverflow.com/questions/781 ... is-a-doubl

Вернуться в «C++»