put what you get from the file into a string, then extract numbers from the sting ,store them into float variable.
Code:
#include<iostream>
#include<iomanip>
#include<fstream>
#include<string>
#include<sstream>
using namespace std;
int main()
{
fstream openf;
string filecontents;
char read;
float numbers;
openf.open("d:\\test.txt",fstream::in);
while(openf.get(read))filecontents+=read;
for(int num1=0,num2=0;num1<=filecontents.size();num1++)
{
if(filecontents.substr(num1,1)==" "||filecontents.substr(num1,1)=="\0")
{
istringstream istream(filecontents.substr(num2,num1-num2));
istream>>numbers;
cout<<numbers<<endl;;
num2=num1+1;
}
}
return 0;
}