#include <stdio.h>
int main()
{
char citta[256];
int temperatura, i;
char nomefile[]="temperature.txt" ;
FILE *Fp1; Fp1 = fopen(nomefile, "w+");
if (Fp1==NULL){
printf("File %s not found\n", nomefile);
exit(-1);
} for (i=0; i<4; i++)
{
printf("Inserire Citta': "); scanf("%s", citta);
printf("Inserire Temperatuta: "); scanf("%d", &temperatura);
fprintf(Fp1, "%s\t%d\n", citta, temperatura);
fflush(stdin);
} rewind(Fp1); printf("\n\nTemperature:\n");
while ( fscanf(Fp1, "%s\t%d\n", citta, &temperatura) == 2 )
{
printf("%s, %d\n", citta, temperatura);
}
fflush(Fp1);
fclose(Fp1);
fflush(stdin);
getchar();
exit(0);
}