Please help with data input to array

I have been trying to figure this out for hours and have searched the internet extensively but cannot figure this out. All I need to do is to input the values from a data file located in my project folder into a one dimensional array. This is what I've tried.

#include <iostream>
#include <fstream>

using namespace std;

int main()
{

int i=0;
int size=57;
int RefSig[size];

ifstream RefSigFile;

RefSigFile.open("/Users/TheLagrangePoint/Dropbox/School/Computer Programming/LAST ONE/ReferenceSignal.txt");

for(i=0; i<size; i++)
{
RefSigFile >> RefSig[i];
std::cout << RefSig[i] << endl;
}

return 0;
}

The output shows 57 zeros, and should be 57 different numbers. Note that the numbers in the fila are decimals such as 0.44, does this affect anything? It is definitely not having trouble locating the file either because I have done several tests to debunk that such as if(!filename) then output error message, and it doesn't output error message.

Please help me.
Last edited on
the Lagrange point wrote:
Note that the numbers in the fila are decimals such as 0.44, does this affect anything?
Yes. int can only store integers. Use type double instead.
Peter87

Words cannot express my gratitude. Wow I cannot believe I didn't realize this. Thank You.
Topic archived. No new replies allowed.