Ver Mensaje Individual
  #4 (permalink)  
Antiguo 29/11/2009, 15:25
ozckar
 
Fecha de Ingreso: noviembre-2009
Mensajes: 3
Antigüedad: 15 años, 3 meses
Puntos: 0
Respuesta: m podrian ayudar porfavor!!!!!!!!!

#include <stdio.h>

void menu();
void CrearFichero(FILE *Fichero);
void InsertarDatos(FILE *Fichero);
void VerDatos(FILE *Fichero);

struct sRegistro {
char Nombre[25];
int Edad;
float Sueldo;

} registro;

int main(int argc, char** argv)
{
int a[60];
int opcion;
int exit = 0;
FILE *fichero;

while (!exit)
{
menu();
printf("\nOpcion: ");
scanf("%d", &opcion);

switch(opcion)
{
case 1:
CrearFichero(fichero);
break;
case 2:
InsertarDatos(fichero);
break;
case 3:
VerDatos(fichero);
break;
case 4:
exit = 1;
break;
default:
printf("\nopcion no valida");
}
}

return 0;
}

void menu()
{
printf("\nMenu:");
printf("\n\t1. Crear fichero");
printf("\n\t2. Insertar datos");
printf("\n\t3. Ver datos");
printf("\n\t4. Salir");
}

void CrearFichero(FILE *Fichero)
{
Fichero = fopen("fichero", "r");

if(!Fichero)
{
Fichero = fopen("fichero", "w");
printf("\nArchivo creado!");
}
else
{
printf("\nEl fichero ya existe!");
}

fclose (Fichero);

return;
}

void InsertarDatos(FILE *Fichero)
{
Fichero = fopen("fichero", "r+");

if(Fichero == NULL)
{
printf("\nFichero no existe! \nPor favor creelo");
return;
}
int a[10];
printf("\nDigita el archivo a comprimr: ");
scanf("%d",a);


fwrite(&registro, sizeof(struct sRegistro), 1, Fichero);

fclose(Fichero);

return;
}

void VerDatos(FILE *Fichero)
{
int numero = 1;

Fichero = fopen("fichero", "r");

if(Fichero == NULL)
{
printf("\nFichero no existe! \nPor favor creelo");
return;
}

fread(&registro, sizeof(struct sRegistro), 1, Fichero);



while(!feof(Fichero))
{
printf("\n%d" );
fread(&registro, sizeof(struct sRegistro), 1, Fichero);
numero++;
}

fclose(Fichero);

return;
}
mira aki esta mi codigo