convert string of ints and floats to a float array in C -


what i'm trying send string on network. point server receives string must make sum of numbers , send back. think easiest way take string , put in float array (it not matter if ints in there aswell, since final sum float number).

unfortunately have no idea how that, or more exactly, how approach it. how take numbers 1 1 string (let's say, each number separated space)? there must function can't find it.

the language plain c under unix.

use strtod() convert first number in string double. add sum, use endptr return value argument figure out if need convert another, , if where. iterate until entire string has been processed.

the prototype strtod() is:

double strtod(const char *nptr, char **endptr); 

also note can run precision issues when treating integers floating-point.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -