hello all,
please help me to understand the following code; it compile fine but the it gives the correct result only for a word of length =< 3. However if I comment out the statement printf("len = %d\n",len) it works fine for all inputs.
Code:
# include <stdio.h>
# include <string.h>
char *ptr;
int main(int args, char *argv[]){
int len = strlen(argv[1]);
//printf("len = %d\n",len);
int j = len - 1, i;
char ch[len];
for( ptr=argv[1],i=0; i<len; i++,j--){
ch[i]=*(ptr + j);
}
printf(ch);
printf("\n");
system("PAUSE");
}