Ask your own question, for FREE!
Computer Science 17 Online
OpenStudy (anonymous):

whats wrong with the c code ?? it has to convert string to ASCII values char by char .. #include #include #include #include int main() { int len,ctr,x; char str[100],ch; int c; puts("Enter the string to be encrypted "); gets(str); printf("the entered string is :\t "); puts(str); len = strlen(str); printf("the lenght of the string is : %d \n",len); for(ctr=0;ctr<=len;ctr++) { c = str[ctr]; printf("%d\n",x); } return 0; }

OpenStudy (anonymous):

You are overstepping the bounds of the string in the loop. The string ranges from 0 to length-1, hence the equals is not correct. Also you can directly print the characters inside printf. #include<stdio.h> #include<string.h> int main() { int len,ctr,x; char str[100],ch; int c; puts("Enter the string to be encrypted "); gets(str); printf("the entered string is :\t "); puts(str); len = strlen(str); printf("the lenght of the string is : %d \n",len); for(ctr=0;ctr<len;ctr++) { printf("%d\n",str[ctr]); } return 0; }

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!