Advertisement
tyotyotyo

strtok strtod

May 8th, 2022
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.34 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main()
  6. {
  7.     char str[] = " 123.42 623.552 \r\n0.342 -0.001";
  8.    
  9.     char * pch;
  10.     pch = strtok (str," \r\n");
  11.   while (pch != NULL)
  12.   {
  13.       double d = strtod(pch, NULL);
  14.     printf ("%s [%f]\n",pch, d);
  15.     pch = strtok (NULL, " \r\n");
  16.   }
  17.  
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement