COMO CAMBIAR Y VALIDAR LA FECHA DEL SISTEMA
AMIGOS, REALMENTE ESTOY EN UN PROBLEMA, TENGO QUE HACER UN PROGRAMA, EN EL CUAL EL USUARIO INGRESANDO EN UN PATH FICTICIO LA PALABRA "FECHA" MUESTRE LA FECHA DEL SISTEMA" Y PERMITA MODIFICARLA, HE BUSCANDO FUNCIONES PERO ESTOY SUPER PERDIDA, SOY PRINCIPIANTE EN C, Y NO SE NI SIQUIEREA COMO CAMBIARLA, YA QUE HICE UN PEQUEÑO PROGRAMA Y CAMBIA SOLAMENTE EL VALOR DEL CONTENIDO DE LAS VARIABLES, PERO NO LA DEL SISTEMA, NO LA QUE ESTA EN WINDOWS. O DOS. POR FAVOR SI ALGUIEN PUEDE ORIENTARME REALMENTE LO NECESITO. GRACIAS
Mira este trozo de codigo te muestra la fecha y hora actual ,hace uso de la libreria time.h ,con respecto a lo de cambiar la fecha del sistema ,dependera del sistema operativo que uses ,si usas windows deberas hacer uso del api de windows y usar la funcion SetLocalTime() y se es para msdos o lo haces con alguna interrupcion de la bios como la 1A05 y la 1A03 o desconozco si hay alguna libreria en dos.h u otra libreria que te deje cambiarlo ,quiza haya alguna
void main()
{
struct tm *tr;
time_t t;
t=time(NULL);
tr=gmtime(&t);
ctime(&t);
printf("la hora y fecha acual es: %s ",asctime(tr));
}
void main()
{
struct tm *tr;
time_t t;
t=time(NULL);
tr=gmtime(&t);
ctime(&t);
printf("la hora y fecha acual es: %s ",asctime(tr));
}
Se me olvidaba ,que igual te sirve aunque no tiene que ver mucho con la programacion .
Puedes hacer uso de la libreria stdlib.h y ejecutar comandos de sistema ,por ejemplo:
system("time");
system("date");
Que te dan la hora y el dia ,ej:
#include <stdlib.h>
#include <stdio.h>
int main()
{
char opcion;
for(;;)
{
system("cls");
printf("1.- Ver la hora");
printf("n2.- Ver la fecha");
printf("n3.- Cambiar la hora");
printf("n4.- Cambiar la fecha");
printf("n5.- Salir del programann");
opcion=getchar();
printf("nn");
switch(opcion)
{
case '1':
system("time /T");
printf("nn");
system("pause");
break;
case '2':
system("date /T");
printf("nn");
system("pause");
break;
case '3':
system("time");
break;
case '4':
system("date");
break;
case '5':
return 1;
}
}
}
Puedes hacer uso de la libreria stdlib.h y ejecutar comandos de sistema ,por ejemplo:
system("time");
system("date");
Que te dan la hora y el dia ,ej:
#include <stdlib.h>
#include <stdio.h>
int main()
{
char opcion;
for(;;)
{
system("cls");
printf("1.- Ver la hora");
printf("n2.- Ver la fecha");
printf("n3.- Cambiar la hora");
printf("n4.- Cambiar la fecha");
printf("n5.- Salir del programann");
opcion=getchar();
printf("nn");
switch(opcion)
{
case '1':
system("time /T");
printf("nn");
system("pause");
break;
case '2':
system("date /T");
printf("nn");
system("pause");
break;
case '3':
system("time");
break;
case '4':
system("date");
break;
case '5':
return 1;
}
}
}
Se me olvidaba ,que igual te sirve aunque no tiene que ver mucho con la programacion .
Puedes hacer uso de la libreria stdlib.h y ejecutar comandos de sistema ,por ejemplo:
system("time");
system("date");
Que te dan la hora y el dia ,ej:
#include <stdlib.h>
#include <stdio.h>
int main()
{
char opcion;
for(;;)
{
system("cls");
printf("1.- Ver la hora");
printf("n2.- Ver la fecha");
printf("n3.- Cambiar la hora");
printf("n4.- Cambiar la fecha");
printf("n5.- Salir del programann");
opcion=getchar();
printf("nn");
switch(opcion)
{
case '1':
system("time /T");
printf("nn");
system("pause");
break;
case '2':
system("date /T");
printf("nn");
system("pause");
break;
case '3':
system("time");
break;
case '4':
system("date");
break;
case '5':
return 1;
}
}
}
Puedes hacer uso de la libreria stdlib.h y ejecutar comandos de sistema ,por ejemplo:
system("time");
system("date");
Que te dan la hora y el dia ,ej:
#include <stdlib.h>
#include <stdio.h>
int main()
{
char opcion;
for(;;)
{
system("cls");
printf("1.- Ver la hora");
printf("n2.- Ver la fecha");
printf("n3.- Cambiar la hora");
printf("n4.- Cambiar la fecha");
printf("n5.- Salir del programann");
opcion=getchar();
printf("nn");
switch(opcion)
{
case '1':
system("time /T");
printf("nn");
system("pause");
break;
case '2':
system("date /T");
printf("nn");
system("pause");
break;
case '3':
system("time");
break;
case '4':
system("date");
break;
case '5':
return 1;
}
}
}
Se me olvidaba ,que igual te sirve aunque no tiene que ver mucho con la programacion .
Puedes hacer uso de la libreria stdlib.h y ejecutar comandos de sistema ,por ejemplo:
system("time");
system("date");
Que te dan la hora y el dia ,ej:
#include <stdlib.h>
#include <stdio.h>
int main()
{
char opcion;
for(;;)
{
system("cls");
printf("1.- Ver la hora");
printf("n2.- Ver la fecha");
printf("n3.- Cambiar la hora");
printf("n4.- Cambiar la fecha");
printf("n5.- Salir del programann");
opcion=getchar();
printf("nn");
switch(opcion)
{
case '1':
system("time /T");
printf("nn");
system("pause");
break;
case '2':
system("date /T");
printf("nn");
system("pause");
break;
case '3':
system("time");
break;
case '4':
system("date");
break;
case '5':
return 1;
}
}
}
Puedes hacer uso de la libreria stdlib.h y ejecutar comandos de sistema ,por ejemplo:
system("time");
system("date");
Que te dan la hora y el dia ,ej:
#include <stdlib.h>
#include <stdio.h>
int main()
{
char opcion;
for(;;)
{
system("cls");
printf("1.- Ver la hora");
printf("n2.- Ver la fecha");
printf("n3.- Cambiar la hora");
printf("n4.- Cambiar la fecha");
printf("n5.- Salir del programann");
opcion=getchar();
printf("nn");
switch(opcion)
{
case '1':
system("time /T");
printf("nn");
system("pause");
break;
case '2':
system("date /T");
printf("nn");
system("pause");
break;
case '3':
system("time");
break;
case '4':
system("date");
break;
case '5':
return 1;
}
}
}
