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 * p;
  10. uint8_t cnt = 0;
  11. *build = 0;
  12. memcpy(copy, buildNumber, numChars);
  13. p = &copy[0];
  14. while(*p != '\0' && cnt < 3)
  15. {
  16. if(*p++ == '.')
  17. {
  18. cnt++;
  19. }
  20. }
  21. *build = (uint16_t)atoi(p);
  22. }
  23.  
  24. char ary[14] = { "0.0.0.65534" };
  25. int main(void) {
  26. uint16_t d = 0;
  27. GetBuildNumber(ary, &d, 14);
  28. printf("%i", d);
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0s 4364KB
stdin
Standard input is empty
stdout
65534