Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How do you join three float values into a comma separated string, and then split it again?


Not sure what you mean but would

  s8 buf[enoughspace];
  snprintf(buf, sizeof(buf), "%f,%f,%f", your, three, values);
  sscanf(buf, "%f,%f,%f", &your,  &three, &values);
Do the job?


I think that the GP was making a commentary on the sorry state of locale handling in C.

You need to first store the current locale, change the locale to one that doesn't use a comma as the decimal point, perform the above, and set the locale back. Plus, there's no threadsafe way to do this, since the locale is process-wide.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: