This program is supposed to take a user input string and change lower case characters to upper case and vice versa. It works except that for spaces between words it puts @ and then it adds some weird characters at the end of every string. What is wrong?
Code:#include<stdio.h> #include<string.h> int main(){ char str[20]; int i; printf("Enter any string:"); gets(str); for(i=0;i<=strlen(str);i++){ if(str[i]>=97&&str[i]<=122) str[i]=str[i]-32; else str[i]=str[i]+32; } printf("Proper capitalisation is of great importance\n"); printf("%s\n",str); return 0; }



LinkBack URL
About LinkBacks



