fork(2) download
  1. #include <stdio.h>
  2.  
  3. #define TEST_BUFFER_CHARS 255
  4. #define DIM(x) (sizeof(x)/sizeof((x)[0]))
  5.  
  6. int main(void)
  7. {
  8. int i;
  9. char testBuffer[TEST_BUFFER_CHARS] = {'\0'};
  10. char *loc = testBuffer;
  11. size_t testBufferSpace = TEST_BUFFER_CHARS;
  12. size_t tempLen;
  13. float testFloats[] = { 1.1, 1.2, 1.3, 1.4 };
  14.  
  15. for(i = 0; i < DIM(testFloats); ++i)
  16. {
  17. snprintf(loc, testBufferSpace, "%f, ", testFloats[i]);
  18. tempLen = strlen(loc);
  19. loc += tempLen;
  20. }
  21.  
  22. printf(testBuffer);
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
1.100000, 1.200000, 1.300000, 1.400000,