I'm having a problem with cin.get()
:
While getting a char, I am converting it to int, but when I enter it through console, the result is different than when its already set in code.
Here is example:
int ord(unsigned char chr){
int ret=int(chr);
return ret;
}
int main(){
unsigned char chr='ň'; //This is my constant character 'ň' for now
cout<<ord(chr)<<endl; //outputs : 242 ,which is alright for me, because it is same as in PHP and that I need
chr=cin.get(); //now I change my constant character 'ň' to 'ň' written through console
cout<<ord(chr)<<endl; //outpus : 229 ,which is wrong for me, because its not same as in PHP
}
How can I fix this?
I want to get 242, not 229, it must be same as ord()'s result in PHP.