Based on ifstream I am using the following function to read filename.txt file
//reading from text file
static std::vector<double> vec;
double a[18]; //values got read from txt file
int i = 0;
void readDATA()
{
double value;
std::ifstream myFile;
myFile.open("filename.txt", std::ios::app);
if (myFile.is_open())
{
std::cout << "File is open." << std::endl;
while (myFile >> value)
{
vec.push_back(value);
std::cout << "value is " << value << std::endl;
a[i] = value;
std::cout << "a" << i << "=" << a[i] << std::endl;
i = i + 1;
}
myFile.close();
}
else
std::cout << "Unable to open the file";
}
it works correctly Below is the content of filename.txt file:
0 0 40 45 15
0 1 40 -45 10
0 0 180 90 15
Could you please help me in modifying the function such that I can read the same .txt file with comma separation between the elements?