fork download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4.  
  5. int main(int argc, char **argv)
  6. {
  7. int i,j,max;
  8. int *lengths;
  9.  
  10. if (argc > 1) {
  11. // space on the heap to store the lengths of all the input arguments
  12. lengths = (int *) malloc( (argc-1) * sizeof(int) );
  13.  
  14. // compute the lengths of all the arguments and remember the maximum
  15. for (i=1; i < argc; i++) {
  16. lengths[i-1] = strlen(argv[i]);
  17. if (lengths[i-1] > max)
  18. max = lengths[i-1];
  19. }
  20.  
  21. // print all the letters
  22. for (j=0; j < max; j++) {
  23. for (i=1; i < argc; i++) {
  24. if (j <= lengths[i-1])
  25. printf("%c ", argv[i][j]);
  26. else
  27. printf(" ");
  28. }
  29. printf("\n");
  30. }
  31. }
  32.  
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0s 5296KB
stdin
Standard input is empty
stdout
Standard output is empty