Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/05/2015, 22:35
Avatar de detective_jd
detective_jd
 
Fecha de Ingreso: abril-2011
Ubicación: Salto
Mensajes: 437
Antigüedad: 13 años
Puntos: 6
tildes y acentuación en c++/linux

Hola a todos, tengo el sgte problema:
Intento hacer un programa que convierte los caracteres de un string en mayúsculas pero cuando se trata de convertir ñ o letras con tilde, no me las convierte.

acá muestro el código:

#include <ctype.h>
#include <iostream>
#include <locale>
using namespace std;
int main() {
setlocale (LC_ALL, "spanish");
string s;
cout << "Ingrese una frase hasta '.': " << endl;
getline(cin,s);
for(int x=0;x<s.size();x++){
if(s[x]==char(-92)){
s[x]=char(-91);
}
else
{
s[x]=toupper(s[x]);
}
}
cout << "\n Resultado: " << s;
return 0;
}

y lo que sale en consola:

Ingrese una frase hasta '.':
ñoño

Resultado: ñOñO
RUN FINISHED; exit value 0,; real time: 2s; user: 0ms; system: 0ms

Agradezco cualquier ayuda, saludos