Registro de trabajadores en c
#include
#include
#include
#include
void cficherot(FILE*trab);
void insertardatos(FILE*trab);
void verdatos(FILE*trab);
struct sregistro
{
char nombre[25], apellido[25],direccion[25], telefono[25];
long int cedula;
}registro;
void cficheroa(FILE*reg);
void indatos(FILE*reg);
void verdatosd(FILE*reg);
voidverdatosh(FILE*reg);
void datosper(FILE*reg);
struct sregistro2
{
long int cedula;
int d,m,a,horae,horas,mine,mins;
}registro2;
void insertardatos2();
void registrot();
void menuprincipal();
void main()
{
clrscr();
int opcion,salir;
salir=0;
while (salir==0)
{
menuprincipal();
gotoxy(15,14); printf("Opcion: ");
scanf("%d", &opcion);
clrscr();if(opcion==1)
{
insertardatos2();
}
if(opcion==2)
{
registrot();
}
if(opcion==3)
{
salir=1;
}
else
{
printf("\nopcion no valida");
}
}
}
void menuprincipal()
{
gotoxy(15,4);printf (" MENU PRINCIPAL ");
gotoxy(15,5);printf("====================================================");
gotoxy(15,8);printf ("(1)Inserci¢n y eliminacion de datos de un trabajador");
gotoxy(15,9);printf ("(2)Registro de la asistencia un trabajador");
gotoxy(15,10);printf("(3)Salir");
}
void insertardatos2()
{
int opcion2;
clrscr();
FILE *trab;
printf("\nMenu:");
printf("\n\t1. Crear fichero");
printf("\n\t2. Insertar datos");
printf("\n\t3. Ver datos");printf("\n\t4. Eliminar datos");
printf("\n\t5. volver");
printf("\nOpcion:");
scanf("%d", &opcion2);
if(opcion2==1)
{
cficherot(trab);
getche();
insertardatos2();
}
if(opcion2==2)
{
insertardatos(trab);
getche();
insertardatos2();
}
if(opcion2==3)
{
verdatos(trab);
getche();
insertardatos2();
}
elseif(opcion2==5)
{
clrscr();
menuprincipal();
}
}
void registrot()
{
int opcion3;
clrscr(); FILE *reg;
printf("\nMenu:");
printf("\n\t1. Crear fichero");
printf("\n\t2. Insertar datos");
printf("\n\t3. cantidad de dias trabajados");
printf("\n\t4. cantudad de horas trabajadas");
printf("\n\t5. datos personal segun el mes");printf("\n\t6.volver");
printf("\nOpcion:");
scanf("%d", &opcion3);
if(opcion3==1)
{
cficheroa(reg);
getche();
registrot();
}
if(opcion3==2)
{
indatos(reg);
getche();
registrot();
}
if(opcion3==3)
{
verdatosd(reg);
getche();
registrot();
}
if(opcion3==4)
{
verdatosh(reg);
registrot();
}
if(opcion3==5){
datosper(reg);
registrot();
}
else
if(opcion3==6)
{
clrscr();
menuprincipal();
}
}
void cficherot(FILE*trab)
{
trab=fopen("trab","r");
if (!trab)
{
trab=fopen("trab","w");
printf("archivo creado!");
}
else
{
printf("el fichero ya existe!");
}
fclose(trab);
return;
}
voidinsertardatos(FILE*trab)
{
trab=fopen("trab","r");
if(trab==NULL)
{
printf ("fichero no existe! por favor creelo");
return;
}
trab=fopen("trab", "a+");
printf("introduzca el nombre:");
scanf("%s",registro.nombre);
printf("introduzca el apellido:");
scanf("%s", registro.apellido);
printf("introduzca el n£mero de c‚dula:");
scanf("%ld",& registro.cedula);printf("introduzca la direccion:");
scanf("%s",®istro.direccion);
printf("introduzca el n£mero de tel‚fono:");
scanf("%s",& registro.telefono);
fwrite(®istro,sizeof(struct sregistro),1,trab);
fclose(trab);
return;
}
void verdatos(FILE*trab)
{
trab=fopen("trab","r");
if(trab==NULL)
{
printf ("fichero no existe! por favor creelo");
return;...
Regístrate para leer el documento completo.