i'm trying print out characters given input command-line arguments. i'm having bit of trouble wrapping head around this.
when run ./test foo bar want print
./test foo o o bar r
while might not best solution, want done using arrays of arrays of chars, , looks three-dimensional array, i'm going triple-nested for-loop. have far this:
for (i = 1; < argc; i++) { (j = 0; j < argv[argc][j]; j++) { (k = 0; k < argv[argc][j]; k++) { printf("%c", k); } } printf("\n"); }
the outermost loop starts @ 1, since don't want print out ./test
-bit. i'm lost. can work two-dimensional arrays, wanted try out dimension.
can give me few pointers?
your condition(j < argv[argc][j]
, k < argv[argc][j]
) wrong.
fix this:
#include <stdio.h> int main(int argc, char *argv[]){ (int = 0; < argc; i++) { puts(argv[i]); if(i){ for(int j = 1; argv[i][j]; ++j){ printf("%c\n", argv[i][j]); } printf("\n"); } } return 0; }
Comments
Post a Comment