-
-
Save ernestoalejo/2472481 to your computer and use it in GitHub Desktop.
sss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <windows.h> | |
using namespace std; | |
#define TAMANIO_MAXIMO 0x1000 | |
wstring ReadLine() { | |
const HANDLE stdIn = GetStdHandle(STD_INPUT_HANDLE); | |
WCHAR buffer[TAMANIO_MAXIMO]; | |
DWORD numRead = 0; | |
if (!ReadConsoleW(stdIn, buffer, sizeof buffer, &numRead, NULL)) | |
return wstring(""); | |
const wstring line(buffer, numRead - 2); | |
return line; | |
} | |
void WriteLine(wstring line) { | |
const HANDLE stdOut = GetStdHandle(STD_OUTPUT_HANDLE); | |
DWORD numWritten = 0; | |
WriteConsoleW(stdOut, line.c_str(), line.size(), &numWritten, NULL); | |
} | |
int main() | |
{ | |
wstring palabra(ReadLine()); | |
// Usa WriteLine() solo si quieres imprimir un objeto wstring, en | |
// lugar del cout normal que usarás para el resto de cadenas | |
// (las cadenas con acentos que compiles irán bien) | |
WriteLine(palabra); | |
if(palabra == L"España") | |
cout << "es igual" << endl; | |
else | |
cout << "mal" << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment