You can use for example the following approach.
#include <stdio.h>
int main( void )
{
const char *s = " 123.321 456.654 789.987";
enum { N = 10 };
double a[N] = { 0.0 };
int pos = 0;
size_t n = 0;
while ( n < N && sscanf( s += pos, "%lf%n", a + n, &pos ) == 1 ) n++;
for ( size_t i = 0; i < n; i++ ) printf( "%.3f ", a[i] );
putchar( '\n' );
}
The program output is
123.321 456.654 789.987
Or you can introduce an intermediate pointer of the type const char * if you need to keep the original address of the string in the variable s.
For example
#include <stdio.h>
int main( void )
{
const char *s = " 123.321 456.654 789.987";
enum { N = 10 };
double a[N] = { 0.0 };
int pos = 0;
size_t n = 0;
const char *p = s;
while ( n < N && sscanf( p += pos, "%lf%n", a + n, &pos ) == 1 ) n++;
for ( size_t i = 0; i < n; i++ ) printf( "%.3f ", a[i] );
putchar( '\n' );
}
strtodmaking use ofendptrparameter to step through the string retrieving doubles as you go. There are probably 50 examples on this site. You can also usestrtokto tokenize the string, see How to extract numbers from string and save them into its own buffer?.