I'm using gedit and my complier is clang. I've been getting a couple of these errors recently and not sure how to fix (error in title and referring to the else statement).
if(isupper(ptext[i]))
if ((((ptext[i]+k)%26)+52) < 65 || (((ptext[i]+k)%26)+52) > 90)
{
printf("%c", (((ptext[i]+k)%26)+78));
}
else
{
printf("%c", (((ptext[i]+k)%26)+52));
}
What should I add/remove/fix? Thanks in advance :)
Your outer if
is missing the braces:
if(isupper(ptext[i]))
{
if ((((ptext[i]+k)%26)+52) < 65 || (((ptext[i]+k)%26)+52) > 90)
{
printf("%c", (((ptext[i]+k)%26)+78));
}
else
{
printf("%c", (((ptext[i]+k)%26)+52));
}
}
Personally, I would extract some of the common elements into variables:
char something1 = ptext[i];
if(isupper(something1))
{
char something2 = (something1+k)%26;
if ((something2+52) < 65 || (something2+52) > 90)
{
printf("%c", (something2+78));
}
else
{
printf("%c", (something2+52));
}
}
And maybe even put a char something3 = something2 + 52;
in there too. Of course, with more meaningful variable names.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With