Article View: es.comp.os.linux.programacion
Article #5912Re: [C] Introducir datos en modo oculto
From: Fernando Arbeiza
Date: Mon, 01 Sep 2003 10:49
Date: Mon, 01 Sep 2003 10:49
56 lines
2338 bytes
2338 bytes
Hola:
On Mon, 01 Sep 2003 12:12:38 +0200, Eris Pluvia
<eris_pluviaNOSPAM@yahoo.es> wrote:
> Estoy buscando una funci�n parecida a 'gets' pero ocultando lo que se
> teclea.
�Te refieres a una funci�n tan peligrosa como gets? ;-)
> Me da igual si es con el cursor inm�vil o con asteriscos. Prefiero
> lo m�s est�ndar.
Pues no, una forma est�ndar no hay, tendr�s que utilizar los servicios
del terminal o alguna librer�a. Puedes leer sobre ello aqu�:
<URL: http://www.eskimo.com/~scs/C-faq/q19.1.html>
En resumen, puedes utilizar la librer�a ncurses. Un ejemplillo:
/**********************************/
#include <ncurses.h>
#define NUM_CHAR 256
int main(void) {
char frase[NUM_CHAR];
initscr();
noecho();
getnstr(frase, NUM_CHAR);
printw("%s", frase);
refresh();
getch();
endwin();
return 0;
}
/**********************************/
Tambi�n puedes utilizar el comando stty, m�s o menos as�:
system("stty -echo")
pregunta_frase();
system("stty echo")
O con funciones POSIX, como puedes leer en:
<URL: http://www.erlenstar.demon.co.uk/unix/faq_4.html#SEC48>
Un saludo.
--
Fernando Arbeiza <URL: mailto:arbeizaf@ono.com>
Crea tu propio Linux: <URL: http://www.escomposlinux.org/lfs-es>
Technical Details
Message-ID:
<slrnbl6913.1lb.arbeizaf@jupiter.olimpo.homelinux.org>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!in.100proofnews.com!in.100proofnews.com!fu-berlin.de!uni-berlin.de!81-203-248-186.user.ono.COM!not-for-mailReferences:
<biv62v$d45gm$1@ID-158102.news.uni-berlin.de>Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII X-Google-Thread: f86c8,63ddb766068b04b4 X-Google-Attributes: gidf86c8,public X-Google-ArrivalTime: 2003-09-01 04:02:17 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!in.100proofnews.com!in.100proofnews.com!fu-berlin.de!uni-berlin.de!81-203-248-186.user.ono.COM!not-for-mail From: Fernando Arbeiza <arbeizaf@ono.com> Newsgroups: es.comp.os.linux.programacion Subject: Re: [C] Introducir datos en modo oculto Date: Mon, 1 Sep 2003 12:49:08 +0200 Lines: 56 Message-ID: <slrnbl6913.1lb.arbeizaf@jupiter.olimpo.homelinux.org> References: <biv62v$d45gm$1@ID-158102.news.uni-berlin.de> NNTP-Posting-Host: 81-203-248-186.user.ono.com (81.203.248.186) Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de 1062414135 14224687 81.203.248.186 (16 [148301]) X-Orig-Path: jupiter.olimpo.homelinux.org!news User-Agent: slrn/0.9.7.4 (Linux)