#include<stdio.h> #include<stdlib.h> #include<string.h> int main(int argc, char **argv) { int i,j,max; int *lengths; if (argc > 1) { // space on the heap to store the lengths of all the input arguments lengths = (int *) malloc( (argc-1) * sizeof(int) ); // compute the lengths of all the arguments and remember the maximum for (i=1; i < argc; i++) { lengths[i-1] = strlen(argv[i]); if (lengths[i-1] > max) max = lengths[i-1]; } // print all the letters for (j=0; j < max; j++) { for (i=1; i < argc; i++) { if (j <= lengths[i-1]) printf("%c ", argv[i][j]); else printf(" "); } printf("\n"); } } return 0; }