To read from standard input
#include <iostream>
int main()
{
float f1, f2, f3, f4;
std::cin >> f1 >> f2 >> f3 >> f4;
}
To read from a file
#include <fstream>
int main()
{
std::ifstream fin("file.txt"); //fin is an arbitrary identifier
float f1, f2, f3, f4;
fin >> f1;
fin >> f2;
fin >> f3;
fin >> f4; // or fin >> f1 >> f2 >> f3 >> f4; no difference
}
To read all floats into an array (vector) of floats, you can use this:
#include <fstream>
#include <vector>
#include <iterator> //for istream_iterator and back_inserter
#include <algorithm> //for copy
int main()
{
std::ifstream fin("input.txt");
std::vector<float> v; //could also initialize with the two-iterator constructor
std::copy(std::istream_iterator<float>(fin),
std::istream_iterator<float>(),
std::back_inserter(v)); //push_back into vector
}
Read more about stream input/output here and elsewhere.
I would also strongly advise that you read a good C++ book