Write a program to find the length of the string entered as command-line input.
#include<stdio.h> #include<stdlib.h> int main(int argc,char**argv) { int i; if(argc < 2) { printf("Enter at least one argument\n"); return 0; } for(i = 0;argv[1][i];i++); printf("Length = %d\n",i); return 0; }
Output
./a.out LotToLearn Length = 10