Write a program to find the length of all strings which are given as command-line input.
#include<stdio.h> #include<stdlib.h> int main(int argc,char**argv) { int i,j; for(j = 1;j < argc;j++) { for(i = 0;argv[j][i];i++); printf("%s Length = %d\n",argv[j],i); } return 0; }
Output
./a.out Lot To Learn Take it Easy Lot Length = 3 To Length = 2 Learn Length = 5 Take Length = 4 it Length = 2 Easy Length = 4