如果我执行此代码(使用命令编译)
gcc accents.c -o accents && cls && accents
)
在Linux DEB(例如Debian或Ubuntu)上,一切正常。
如果我在Windows 10上执行此代码,则不会检测到特殊字符。
如何允许特殊字符(如“Àlex”,即À)在Windows上正常工作?
#include <stdio.h>
void NetejaBuffer(){ while(getchar() != '\n'); }
int comparaCadena(char p1[],char p2[]){
int i=0;
while (p1[i]!='\0'){
if (p1[i]!=p2[i]) return 0;
i++;
}
return 1;
}
int main (){
char Paraula1[30]="Àlex"; // Define Main Word: Àlex
char Paraula2[30]; // Define variable for Second Word
int i=0; // Define no go to the next step beafoure writte Main Word
while (i==0){
printf(" Main Word: "); // Show text "Main Word" on terminal
scanf("%[^\n]",Paraula2); // Ask a word. It will save on "Paraula2" variable
NetejaBuffer();
if(comparaCadena(Paraula1,Paraula2)) {
printf(" NICE! \n "); // If word are the same on Main Word, show text "NICE!"
i=1; // And define variable i as 1
}else printf("TRY AGAIN! \n "); // If word are no the same, show text "TRY AGAIN!"
}
return 0;
}
答案 0 :(得分:-1)
À不是特殊字符。如果您观察ASCII值,将会发现此字符 通过此链接 https://theasciicode.com.ar/extended-ascii-code/letter-a-grave-accent-lowercase-ascii-code-133.html