fork download
  1. #include <cstdio>
  2.  
  3. struct dummyStruct
  4. {
  5. unsigned short min[4];
  6. unsigned short max[4];
  7. int dummyBuffer;
  8. };
  9.  
  10.  
  11. int main()
  12. {
  13. dummyStruct db;
  14. // Note that the size of the short is assumed to be half of that of the %d specifier
  15. sscanf(" 123, 456, 789, 112", "%d, %d, %d, %d", db.min+0, db.min+1, db.min+2, db.min+3);
  16. sscanf("29491, 29491, 29491, 29491", "%d, %d, %d, %d", db.max+0, db.max+1, db.max+2, db.max+3);
  17. db.dummyBuffer = 1234;
  18.  
  19. printf("%hd, %hd, %hd, %hd\n", db.min[0], db.min[1], db.min[2], db.min[3]);
  20. printf("%hd, %hd, %hd, %hd\n", db.max[0], db.max[1], db.max[2], db.max[3]);
  21. printf("%d\n", db.dummyBuffer);
  22.  
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
123, 456, 789, 112
29491, 29491, 29491, 29491
1234