Need help in converting a example string like this:
Example String
into:
eXaMpLe StRiNg
by preserving the whitespaces In C Programming language. I referred to other posts, but didn't find any help for writing in C.
I tried using this logic:
#include<stdio.h>
#include<string.h>
int main()
{
int i,len;
char a[30],b[30];
printf("Enter a string\n");
gets(a);
len=strlen(a);
for(i=0;i<len;i=i+2)
{
if(a[i]!=' ' && isalpha(a[i]))
{
a[i]=tolower(a[i]);
}
else if(a[i]!=' ')
a[i]=toupper(a[i]);
}
printf("New string is %s\n",a);
return 0;
}