cuestion sobre un programita de la hora en c++
Hola a todos!
Estoy haciendo un programa de c++ basicamente como sigue
#include "consola.h"
#include <iostream.h>
#include <time.h>
#include <iostream>
#include <fstream>
#include <string>
#include <conio.h>
#include <ostream>
#include <string>
#include "consola.h"
#define ENTER 0xd // El enter de teclado
void main() {
for (int h=1; h<1000000; h++){
char* ds[7] = {"Domingo","Lunes","Martes","Miercoles","Jueves","Viernes","Sabado"};
char* ms[12] = {"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"};
time_t t;
time(&t);
struct tm* petm = localtime(&t);
long dgt = _timezone/60;
gotoxy (2,2);
cout << ds[petm->tm_wday] << ", " << petm->tm_mday<< " de " << ms[petm->tm_mon] << " del " << "axa4o " << petm->tm_year+1900 << flush;
gotoxy (72,2);
cout << petm->tm_hour << ":" << petm->tm_min << ":" << petm->tm_sec << endl;
sleep(1);
//clrscr();
}
}
Lo k trato de averiguar es como hacer k si no se pulsa el enter, continua corriendo la hora, y si se pulsa, pues hagas cosas como salir x ej
Bueno pues gracias anticipadas a todoss
Ciaoo
Estoy haciendo un programa de c++ basicamente como sigue
#include "consola.h"
#include <iostream.h>
#include <time.h>
#include <iostream>
#include <fstream>
#include <string>
#include <conio.h>
#include <ostream>
#include <string>
#include "consola.h"
#define ENTER 0xd // El enter de teclado
void main() {
for (int h=1; h<1000000; h++){
char* ds[7] = {"Domingo","Lunes","Martes","Miercoles","Jueves","Viernes","Sabado"};
char* ms[12] = {"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"};
time_t t;
time(&t);
struct tm* petm = localtime(&t);
long dgt = _timezone/60;
gotoxy (2,2);
cout << ds[petm->tm_wday] << ", " << petm->tm_mday<< " de " << ms[petm->tm_mon] << " del " << "axa4o " << petm->tm_year+1900 << flush;
gotoxy (72,2);
cout << petm->tm_hour << ":" << petm->tm_min << ":" << petm->tm_sec << endl;
sleep(1);
//clrscr();
}
}
Lo k trato de averiguar es como hacer k si no se pulsa el enter, continua corriendo la hora, y si se pulsa, pues hagas cosas como salir x ej
Bueno pues gracias anticipadas a todoss
Ciaoo
Me la podrias mandar al email ? la consola.h ? : [email protected]
#include "consola.h"
#include <iostream.h>
#include <time.h>
#include <conio.h>
#include <iostream>
#include <fstream>
#include <string>
#include <conio.h>
#include <ostream>
#include <string>
#include "consola.h"
#define ENTER 0xd // El enter de teclado
void main() {
int op=0;
char* ds[7] = {"Domingo","Lunes","Martes","Miercoles","Jueves","Viernes","Sabado"};
char* ms[12] = {"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"};
time_t t;
do
{
time(&t);
struct tm* petm = localtime(&t);
long dgt = _timezone/60;
gotoxy (2,2);
cout << ds[petm->tm_wday] << ", " << petm->tm_mday<< " de " << ms[petm->tm_mon] << " del " << "axa4o " << petm->tm_year+1900 << flush;
gotoxy (72,2);
cout << petm->tm_hour << ":" << petm->tm_min << ":" << petm->tm_sec << endl;
sleep(1);
if(kbhit) //si se pulsa una tecla
op=getch; //se recoge sin eco (sin mostrarla en pantalla)
}while(op!=13); //se ejecuta mientras esa tecla no sea enter
//clrscr();
}
}
Un saludo.
#include <iostream.h>
#include <time.h>
#include <conio.h>
#include <iostream>
#include <fstream>
#include <string>
#include <conio.h>
#include <ostream>
#include <string>
#include "consola.h"
#define ENTER 0xd // El enter de teclado
void main() {
int op=0;
char* ds[7] = {"Domingo","Lunes","Martes","Miercoles","Jueves","Viernes","Sabado"};
char* ms[12] = {"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"};
time_t t;
do
{
time(&t);
struct tm* petm = localtime(&t);
long dgt = _timezone/60;
gotoxy (2,2);
cout << ds[petm->tm_wday] << ", " << petm->tm_mday<< " de " << ms[petm->tm_mon] << " del " << "axa4o " << petm->tm_year+1900 << flush;
gotoxy (72,2);
cout << petm->tm_hour << ":" << petm->tm_min << ":" << petm->tm_sec << endl;
sleep(1);
if(kbhit) //si se pulsa una tecla
op=getch; //se recoge sin eco (sin mostrarla en pantalla)
}while(op!=13); //se ejecuta mientras esa tecla no sea enter
//clrscr();
}
}
Un saludo.
