Enviar Respuesta  Enviar Tema 
gotoxy();
Autor Mensaje
RompeRatones
Usuario PL


Mensajes: 78
Grupo: Registrado
Registro en: May 2005
Estado: Sin Conexión
Reputación: 4
Mensaje: #1
gotoxy();

Este me sirvio perfectamente:

[url=http://www.cprogramming.com/snippets/show.php?tip=16&count=30&page=0 Escribió:
www.cprogramming.com[/url]]
#include <stdio.h> /* sprintf */
#include <string.h> /* strcat */

/*
** gotoxy() Implementation in the *nix environment
**
** Note: I've heard the curses library can be useful
** when trying to implement the handy DOS-only tools of
** gotoxy() and clrscr() using move() and initscr().
** Though, there is a way to write your own gotoxy()
** in the Linux environment. This topic isn't discussed
** often, so I'd like to bring a few new ideas to the table.
**
** Concept: We will use two ANSI C standard functions
** to accomplish our task. We will use specific
** string manuvers, according to the man pages, that
** will allow us to execute each part of the program.
*/
void gotoxy(int x, int y) {
char essq[100]; /* String variable to hold the escape sequence */
char xstr[100]; /* Strings to hold the x and y coordinates */
char ystr[100]; /* Escape sequences must be built with characters */

/*
** Convert the screen coordinates to strings
*/
sprintf(xstr, "%d", x);
sprintf(ystr, "%d", y);

/*
** Build the escape sequence (vertical move)
*/
essq[0] = '\0';
strcat(essq, "\033[");
strcat(essq, ystr);

/*
** Described in man terminfo as vpa=\E[%p1%dd
** Vertical position absolute
*/
strcat(essq, "d");

/*
** Horizontal move
** Horizontal position absolute
*/
strcat(essq, "\033[");
strcat(essq, xstr);
/* Described in man terminfo as hpa=\E[%p1%dG */
strcat(essq, "G");

/*
** Execute the escape sequence
** This will move the cursor to x, y
*/
printf("%s", essq);
}



Perdonen si lo posteo acá, es que se me hace más facil para encontrarlo más tarde.


09-07-2005 03:16 PM
Visita el website del usuario Encuentra todos los mensajes de este usuario Cita este mensaje en tu respuesta
warp
Q


Mensajes: 2,009
Grupo: Registrado
Registro en: Jun 2005
Estado: Sin Conexión
Reputación: 10
Mensaje: #2
RE: gotoxy();

gracias, me alegro de que hayas solucionado tu problema....


09-15-2005 10:29 PM
Visita el website del usuario Encuentra todos los mensajes de este usuario Cita este mensaje en tu respuesta
Enviar Respuesta  Enviar Tema 

Ver la Versión para Impresión
Mandar este Tema a algún Amigo
Subscríbete a este Tema | Agrega este Tema a Tus Favoritos

Salto de Foro: