Since you have taken a line of the file into a string, you can convert the string into a vector of char and make a char* point to this vector and pass the char* into the following function as the first parameter:
char * strtok ( char * str, const char * delimiters );
The second parameter in your case would be a blank space " ". The received char pointer can be then converted to a float and each token can be stored in an array!
int nums(char sentence[ ]) //function to find the number of words in a line
{
int counted = 0; // result
// state:
const char* it = sentence;
int inword = 0;
do switch(*it) {
case '\0':
case ' ': case '\t': case '\n': case '\r':
if (inword) { inword = 0; counted++; }
break;
default: inword = 1;
} while(*it++);
return counted;
}
int main()
{
ifstream file_input (input.c_str());
int row=0;
while ( getline(file_input, abc) )
{
vector<char> writable(abc.begin(), abc.end());
vector<char> buf(abc.begin(), abc.end());
writable.push_back('\0');
buf.push_back('\0');
char *line=&writable[0];
char *safe=&buf[0];
char* s= "123.00";
float array[100];
char *p;
int i=0;
p= strtok (line, " ");
array[i]=atof(p);
cout<<" "<<array[i];
i++;
while (i<nums(safe))
{
p = strtok (NULL, " "); //returns a pointer to the token
array[i]=atof(p);
cout<<" "<<array[i];
i++;
}
return 0;
}
Unfortunately the loop: while(p!=NULL) is not working out and resulting in a segmentation fault so I have had to pre-calculate the number of words in the line using another vector since strtok() modifies the string passed as char* to it.