Está en la página 1de 3

Organización de Archivos

Daniel Suarez Nava


G-42

26/02/19
ALTAS DE REGISTRO DE PRODUCTOS

#include <stdio.h>

#include <string.h>

#include <conio.h>

struct CD

char nombre[20];

char genero[40];

float costo;

int no_prod;

};

struct CD disco;

FILE *fp;

main(){

int serie;
Organización de Archivos
Daniel Suarez Nava
G-42

26/02/19
printf("Tamaño_Estructura: %d bytes",sizeof(disco));

printf("<<\n\r ALTAS DE REGISTROS DE PRODUCTOS");

fp=fopen("ICO.txt","w");

printf("<< \n\r Nombre:");fflush(stdin); gets(disco.nombre);

printf("<< \n\r Genero:");fflush(stdin); gets(disco.genero);

printf("<< \n\r Costo :");fflush(stdin); scanf("%f",&disco.costo);

printf("<< \n\r numero de serie : ");fflush(stdin); scanf("%d",&disco.no_prod);

fwrite(&disco,sizeof(disco),1,fp);

fclose(fp);

printf("<<\n\n\n\rProducto registrado !!!");

getch();

}
Organización de Archivos
Daniel Suarez Nava
G-42

26/02/19

#include <stdio.h>

#include <conio.h>

FILE *fp;

main()

int serie;

if((fp=fopen("ICO.txt","r"))==NULL)

fp=fopen("ICO.txt","w");

fclose(fp);

printf("<<\n\n\n\r ARCHIVO GENERADO!!!");

getch();

También podría gustarte