Article View: es.comp.os.linux.programacion
Article #13597Re: [c]retardos,timers,temporizadores
From: Seldon
Date: Fri, 09 Feb 2001 17:06
Date: Fri, 09 Feb 2001 17:06
61 lines
2733 bytes
2733 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
El Thu, 08 Feb 2001 23:42:34 +0000, David Ram�n Yanes Fari�a no ten�a nada
mejor que hacer, y dijo en es.comp.os.linux.programacion:
>#include <stdio.h>
>#include <time.h>
>
>main(){
> clock_t t2,t1;
> t1=clock();
> sleep(2);
> t2=clock();
> printf ("Diferencia %ld\n",(t2-t1)/CLOCKS_PER_SEC);
>}
Eso mejor hazlo con time:
time_t t1,t2;
t1=time(); /* Es equivalente a time(&t1); */
sleep(2);
t2=time();
printf ("Diferencia: %.0f\n", difftime((time_t)t1, (time_t)t2);
>Otra:
> �de que funciones tengo q tirar para hacer un temporizador?
>me he mirado el man time, clock,alarm etc, pero no me hago una idea,
>lo quiero para ponerlo dentro de un while
>algo asi
>
>time_t t1,t2;
>
>t1=times(&t1);
No se hace eso. Puedes poner 't1=times()' o 'times(&t1)'. Son
equivalentes. Y time_t se usa para time(), y no para times(), que se utiliza
tms.
Mira 'man times.2'. Adem�s, ah� tambi�n viene la estructura tms.
Slds
- --
Seldon (seldon@seldon.4mg.com) - Linux user: 164.255
=================================================
PGP Key: http://pgp5.ai.mit.edu:11371/pks/lookup?op=get&search=0x64794AF8
Fingerprint: DA8F 06A0 B770 4211 A6E7 D1E8 8A03 BC70 6479 4AF8
=================================================
Administrador Lista Hackindex:
hackindex-alta@eListas.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE6hCN0igO8cGR5SvgRAsADAKCuotngQacmy25uIsQafAlNRSinUgCePN6i
OB4eVmoAyow0NEa+vjbpNss=
=9WQv
-----END PGP SIGNATURE-----
Technical Details
Message-ID:
<p18169.k9b.ln@gaia.seldon.4mg.com>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!sn-xit-04!supernews.com!xfer13.netnews.com!netnews.com!newsfeed.skycache.com!Cidera!newsfeed.comtenidos.com!m2newsfeeder01!seldonReferences:
<3A832EEA.C30F2461@bigfoot.com>Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII X-Google-Thread: f86c8,89a84b7821a48b84 X-Google-Attributes: gidf86c8,public X-Google-ArrivalTime: 2001-02-09 10:48:37 PST Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!sn-xit-04!supernews.com!xfer13.netnews.com!netnews.com!newsfeed.skycache.com!Cidera!newsfeed.comtenidos.com!m2newsfeeder01!seldon From: seldon@SPAMseldon.4mg.com (Seldon) Newsgroups: es.comp.os.linux.programacion Subject: Re: [c]retardos,timers,temporizadores Date: Fri, 9 Feb 2001 18:06:01 +0100 Organization: Or-ga-ni-za-ción-ción Lines: 61 Message-ID: <p18169.k9b.ln@gaia.seldon.4mg.com> References: <3A832EEA.C30F2461@bigfoot.com> Reply-To: seldon@SPAMseldon.4mg.com NNTP-Posting-Host: usuario1-36-191-55.dialup.uni2.es Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit X-Trace: m2wpersoisp01.wanadoo.es 981743939 5304 62.36.191.55 (9 Feb 2001 18:38:59 GMT) X-Complaints-To: usenet@m2wpersoisp01.wanadoo.es NNTP-Posting-Date: Fri, 9 Feb 2001 18:38:59 +0000 (UTC) User-Agent: slrn/0.9.6.2 (Linux)