C File Handling Techniques: Data Storage and Retrieval Examples
Classified in Computers
Written on in
English with a size of 4.91 KB
C Example 1: Writing Structured Data to a File
This program demonstrates appending structured date data (assuming struct fecha is defined elsewhere) to a file named Dades.txt. It includes basic file opening and error checking.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int temp = 1;
int auxiliar = 0;
int i = 0;
FILE *v1;
v1 = fopen("Dades.txt", "a");
// Note: Variables 'origen' and 'destino' are undefined in this snippet.
if (origen == NULL || destino == NULL) {
printf("Problemas con los ficheros.\n");
exit(1);
}
printf("Inserte el día, mes y año. El programa finalizará marcando 0 en el día:\n\n");
while (temp != 0) {
printf("Día:\... Continue reading "C File Handling Techniques: Data Storage and Retrieval Examples" »