Hey everyone.. I am having an issue with this program that I am working on.. Not sure if I am using something wrong and should try something different.. but generally I am inputting large double values from a text file.. These values are like: 178909.95 but when I use A[ix] = stod(line).. to convert the string line into a double I only get 178910 and it cuts off the decimal values. I am wondering if it is the stod that is causing it? I have tried using stold and it results in the same issue... Anyway thanks in advance
Here is what my code looks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
double* loadArray(string fileName, int size) {
string line;
ifstream file;
double* A = newdouble[size];
int ix = 0;
file.open(fileName);
if (file.is_open()) {
while (getline(file, line)) {
A[ix] = stod(line);
ix++;
}
file.close();
}
return A;
}
These values are like: 178909.95 but when I use A[ix] = stod(line).. to convert the string line into a double I only get 178910 and it cuts off the decimal values.
What makes you think it's cutting off the value?
What would you expect the following program's output to be?