Skip to content
Snippets Groups Projects
doubles.c 400 B
Newer Older
#include <stdio.h>
#include <stdlib.h>

#define STR "1.2 2.3 3.4 4.5 5.6 6.7 7.8"
#define LEN 7

int
main (void)
{
    char *str = STR;
    char *rem = str;
    double arr[LEN];

    for (int i = 0; i < LEN; i++)
    {
        double val = strtod (rem, &rem);
        arr[i] = val;
    }

    for (int i = 0; i < LEN; i++)
        printf ("Value %d is %lf\n", i, arr[i]);

    return EXIT_SUCCESS;
}