I have the following code:
#include <iostream>
#include <cstdlib>
int main(){
string letra = "méxico";
for(int i=0;i<letra.size();i++){
cout << letra[i] << endl;
}
return 0;
}
What I get as a result:
m
�
�
x
i
c
o
Why are 7 characters instead of 6?, If I do this:
cout << letra << endl;
I get:
méxico
What's going on? I've tried using
setlocale(LC_ALL,es_MX.UTF-8);
setlocale(LC_ALL,"");
And although the function does not return "NULL", it does not work. I use Codeblocks 16.01, gcc 4.9, g++ 4.9 on Linux.