PDB1982 0 Posting Whiz in Training

How would I, if it's even possible, create an array to read/store the input values from a input text file? Here is what I was thinking, but I want to pretend as if I don't know the amount of values in the file.

Input File Has: 21.22, 13.23, 43.12, 123.54, 656.10
But the program should be unaware of the total...

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cmath>
using namespace std;

int main()
{
	double num[100];
	int j;

	ifstream Input;

	Input.open("InputNumbers.txt");

	if (Input.fail())
	{
		cout << "Can't Open Input File!" << endl;
		exit(1);
	}

	for (j=0;j<100;j++)
	{
		Input >> num[j];
		cout << num[j];
		j++;
	}

	return 0;
}

I know the error lies with me establishing the "100" in the loop, but I don't know who to code for an unknown numbers of variables...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.