fork download
  1. #include <stdio.h>
  2.  
  3. struct Device {
  4. char name[100];
  5. int price;
  6. int quantity;
  7. };
  8.  
  9. void printDevice(struct Device device) {
  10. printf("%s\t%d\t\t%d\n", device.name, device.price, device.quantity);
  11. }
  12.  
  13. int main() {
  14. struct Device devices[] = {
  15. {"CPU_INTEL_CORE_I5_10400F", 5490, 1},
  16. {"ASROCK_B460M_PRO_4", 3050, 1},
  17.  
  18. };
  19. int numDevices = sizeof(devices) / sizeof(devices[0]);
  20.  
  21. printf("Device\tPrice/device\tNumber of devices\n");
  22. for (int i = 0; i < numDevices; i++) {
  23. printDevice(devices[i]);
  24. }
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Device	Price/device	Number of devices
CPU_INTEL_CORE_I5_10400F	5490		1
ASROCK_B460M_PRO_4	3050		1