Advertisement
Guest User

Equivalencias de funciones en linux con windows

a guest
May 28th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. /************************* Gotoxy para Linux ********************************/
  2. /*
  3. //Función para convertir cualquier tipo de datos a string.
  4. template <class T>
  5. inline string ToString(const T& t) {
  6.     stringstream ss;
  7.     ss << t;
  8.     return ss.str();
  9. }
  10.  
  11. //Función para emular al gotoxy en la consola de Linux.
  12. inline string gotoxy(const int& x,const int& y) {
  13.     return "\33[" + ToString(x) + ";" + ToString(y) + "H";
  14. }
  15. */
  16. /************************* Gotoxy para windows ********************************/
  17.  
  18.  void gotoxy(int x,int y){
  19.       HANDLE hcon;
  20.       hcon = GetStdHandle(STD_OUTPUT_HANDLE);
  21.       COORD dwPos;
  22.       dwPos.X = x;
  23.       dwPos.Y= y;
  24.       SetConsoleCursorPosition(hcon,dwPos);
  25.  }
  26.  
  27.  /******************************************************************************/
  28.  
  29. void borrarPantalla(){
  30.   ///system("clear"); //LINUX
  31.   system("cls"); //WINDOWS
  32. }
  33.  
  34. /******************************************************************************/
  35.  
  36. void pausa(){
  37.   system("pause >nul"); //WINDOWS
  38.   /* cout<<"presione enter para continuar"<<endl;   ///LINUX
  39.     cin.ignore ();
  40.     cin.get(); */
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement