Untitled
unknown
plain_text
2 years ago
527 B
10
Indexable
#include <stdio.h> typedef struct { char name[50]; int age; } Persona; int main(){ Persona p; FILE *fbin; fbin = fopen("marta.dat", "wb"); if(fbin == NULL) { printf("Error opening file"); return 1; } else { for(int i = 0; i < 3; i++) { printf("Name: "); scanf("%s", p.name); printf("Age: "); scanf("%d", &p.age); fwrite(&p, sizeof(Persona), 1, fbin); } fclose(fbin); } return 0; }
Editor is loading...