i used fgets and made new var for strlen()
but the same proplem
Code:
#include<stdio.h>
#include<string.h>
#include<stdbool.h>
char toupper(char);
char tolower(char);
bool islower(char);
bool isupper(char);
int main(){
char str[20];
int i;
printf("Enter any string:");
fgets(str,20,stdin);
int len=strlen(str);
for(i=0;i<len;i++){
if(islower(str[i])==1)
toupper(str[i]);
else if(isupper(str[i])==1)
tolower(str[i]);
}
printf("%s\n",str);
return 0;
}
bool islower(char ch){
if(ch>='a'&&ch<='z')
return 1;
else return 0;
}
bool isupper(char ch)
{
if (ch<='A' && ch>='Z')
return 1;
else return 0;
}
char toupper(char ch) {
if (ch <= 'a' && ch >= 'z')
ch=ch+32;
return ch;
}
char tolower(char ch) {
if (ch <= 'A' &&ch >= 'Z')
ch=ch-32;
return ch;
}
thanks for help