fork(1) download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4.  
  5.  
  6. // id is OK as os
  7. int id[36] = {0};
  8. // make first_name and last_name arrays of arrays
  9. char first_name[36][36];
  10. char last_name[36][36];
  11. int i = 0;
  12. while (fscanf(stdin, "%d, %35[^,], %35s", &id[i], first_name[i], last_name[i]) == 3) {
  13. i++;
  14. if (i == 36) {
  15. break;
  16. }
  17. }
  18. for (int j = 0 ; j != i ; j++) {
  19. printf("%d - '%s' - '%s'\n", id[j], first_name[j], last_name[j]);
  20. }
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 2056KB
stdin
1234567, John, Doe
3847234, quick, brown
8828734, fox, jumps
stdout
1234567 - 'John' - 'Doe'
3847234 - 'quick' - 'brown'
8828734 - 'fox' - 'jumps'