fork download
  1. #include <stdio.h>
  2. #include <stdint.h>
  3. #include <stddef.h>
  4. #include <string.h>
  5.  
  6. void GetBuildNumber(char * buildNumber, uint16_t * build, size_t numChars)
  7. {
  8. char copy[numChars];
  9. char * token;
  10. *build = 0;
  11. memcpy(copy, buildNumber, numChars);
  12. printf("%s\r\n", copy);
  13. token = strtok(copy, ".");
  14. printf("%s\r\n", copy);
  15. if(token != NULL)
  16. {
  17. *build = (uint16_t)atoi(token);
  18. }
  19. printf("%s\r\n", copy);
  20. while(token != NULL)
  21. {
  22. token = strtok(NULL, ".");
  23. if(token != NULL)
  24. {
  25. *build = (uint16_t)atoi(token);
  26. printf("%s\r\n", copy);
  27. }
  28. }
  29. }
  30.  
  31. char ary[14] = { "0.0.0.123" };
  32. int main(void) {
  33. uint16_t d = 0;
  34. GetBuildNumber(ary, &d, 14);
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0s 4520KB
stdin
Standard input is empty
stdout
0.0.0.123
0
0
0
0
0