All pastes #1276311 Raw Edit

Unnamed

public c v1 · immutable
#1276311 ·published 2008-12-04 22:29 UTC
rendered paste body
/** *  escribo.c *  * @descripcion escribe estructuras del tipo registro a un fichero      */#include <stdio.h>#include <string.h>/* registro */struct registro{    int edad;    char  nombre[60];};int main(){    int i;    FILE *f; 	struct registro r;    /* creamos 3 registros */    f=fopen("registros.dat","w");        if (!f)    {        return 1;    }    for (i=1;i<=3; i++)    {    	switch(i)    	{    		case 1:    			r.edad=23;    			strcpy(r.nombre,"R-Ratones");    			break;    		case 2:    			r.edad=1000;    			strcpy(r.nombre,"Mun-ra");    			break;    		case 3:    			r.edad=9;    			strcpy(r.nombre,"bart");    			break;    		default:    		break;    	}                fwrite(&r,sizeof(struct registro),1,f);    }    fclose(f);        printf("Datos fueron creados\n");    return 0;}