Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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;
}
like image 504
maalem Avatar asked Mar 26 '11 12:03

maalem


1 Answers

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.

like image 181
Karel Petranek Avatar answered Oct 13 '22 21:10

Karel Petranek