jeudi 24 octobre 2019

I need an IF function to accept UPPERCASE letters only

I need an IF statement to accept UPPERCASE letters only and I want to use ELSE to print an error (or the other way around) for the reason of having fun with run length encoding, but it seems to not work.

Every time I enter even a single character, like A or B - it spits out the error.

This is not what the code really looks like, the IF and ELSE statements are what matters.

#include <stdio.h>

int main()
{
    char current, previous = 0;
    int AoR = 0, unc_am, am, first = 0;

    while(scanf("%c", &current) != EOF)
    {
        if(current <= 'Z' && current >= 'A')
        {RLE}
        else
        {printf error}
    }

What is it that I am doing wrong? Thanks.

Aucun commentaire:

Enregistrer un commentaire