Ver Mensaje Individual
  #2 (permalink)  
Antiguo 02/11/2012, 23:07
ecfisa
 
Fecha de Ingreso: julio-2012
Mensajes: 133
Antigüedad: 11 años, 10 meses
Puntos: 22
Respuesta: poner limitacion de uso o por fecha

Cita:
recuerdo que con if podia hacer que el programa dejara de funcionar el dia programado
Hola yoseoweb.

Código C++:
Ver original
  1. #include <iostream>
  2. #include <ctime>
  3.  
  4. using namespace std;
  5.  
  6. int expired(struct tm);  
  7. ...
  8.  
  9. int main() {
  10.   struct tm f;
  11.   int d,m,y;
  12.   /*  Aquí iría el código para obtener la fecha de finalización desde el archivo.
  13.       Dia, mes y año se almacenarán en las variables: d, m, y. */
  14.   f.tm_year = y;
  15.   f.tm_mon  = m;
  16.   f.tm_mday = d;
  17.   if (expired(f) > 0) {
  18.     cout << "El tiempo de prueba ha expirado";
  19.     cin.get();
  20.     return 0;
  21.   }
  22.   int matriz[3]={0}, len = sizeof(matriz)/sizeof(int);
  23.  
  24.   pedir(matriz, len-1);
  25.   matriz[3] = sumar(matriz, len-1);
  26.   mostrar(matriz, len-1);
  27.   return 0;
  28. }
  29.  
  30. /* expired: devuelve > 0 si ini < hoy, = 0 si ini = hoy, < 0 si ini > hoy */
  31. int expired(struct tm ini) {
  32.   time_t t = time(NULL);
  33.   struct tm *hoy = localtime(&t);
  34.   return (hoy->tm_year+1900 + hoy->tm_mon + hoy->tm_mday) -
  35.          (ini.tm_year + ini.tm_mon+ ini.tm_mday);
  36. }
  37. ...

Saludos.