fork(4) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main(void) {
  6. char* p;
  7. float farr[100];
  8. int i = 0;
  9. //str is your incoming string
  10. char str[100] = "23.5 11.2 7 19.2 17";
  11. p = strtok(str," ");
  12. while (p != NULL)
  13. {
  14. farr[i] = atof(p);
  15. printf("%f\n", farr[i]);
  16. p = strtok(NULL, " ");
  17. }
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
23.500000
11.200000
7.000000
19.200001
17.000000