maalem
maalem

Reputation: 79

Invalid character test

when i execute that with 'é' it is accepted although the test! help!!

#include <stdio.h>
#include <string.h>

int main ()
{
    char  ch[10];
    int i,k,k1;

do
{
    k=0; i=0;   
    printf("Write a sentence without accentuated letters:\n");
    scanf("%s",ch);
    k1=strlen(ch);
    while ((k==0)&&(i<k1))
    {
        if (ch[i]=='é') k=1;
        i++;
    }
}   
while (k==1);

    return 0;
}

Upvotes: 6

Views: 1285

Answers (1)

Karel Petranek
Karel Petranek

Reputation: 15164

The problem is probably with encoding. é can have different numerical representation depending on the encoding standard used. If your source code editor, compiler and your command line use different encodings, things will never work this way. You might want to switch to UTF-8.

Upvotes: 2

Related Questions