to write arrray and structures in a given text file and retrieving it to us in calculation can somebody help me with a sample code this is my code
#include <stdio.h>
#include <stdlib.h>
int main()
{ FILE *file1;
FILE *file2;//declaring two file pointers file1 to read,and file2 to read
file1=fopen("data.txt","w"); //creating a new text file in writing mode
int array1[12],i;//declared array1 which we will input the data in
for(i=0;i<=12;i++){
scanf("%d",&array1[i]);//i am trying to use a for loop to input elements into arrar
fprintf(file1,array1);//am trying to write the gotten values into file1
}
fclose(file1);
file2=fopen("data.txt","r");//in read mode a file2 poninter
int array2[12]; //another array of same number of elements to store the data read from file
while(!feof(file2)){ //to get all the values inthe text file
for(i=1;1<=12;i++){
fscanf(file2,"%d",&array2[i]);//from here i am just confused
printf("%d",array2[12]);
}
}
fclose(file2);
}