#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void stampaTabella(int Base, FILE *Fp1);
int main()
{
int base = -1;
FILE * Fp;
char nomefile[]="TABELLA.TXT" ;
Fp = fopen(nomefile, "w");
if (Fp==NULL)
{
printf("Impossibile aprire il file %s\n", nomefile);
exit(-1);
}
while(base < 1 || base >100)
{
printf("inserire un numero tra 1 e 99: \n");
scanf("%d", &base);
}
stampaTabella(base, Fp);
fflush(Fp);
fclose(Fp);
exit(0);
}
void stampaTabella(int Base, FILE *Fp1)
{
int i;
fprintf(Fp1, "\n--------------------\n");
fprintf(Fp1, "| tabellina del %2d |\n", Base);
fprintf(Fp1, "--------------------\n");
for(i=1; i<=10; i++)
{
fprintf(Fp1, "| %2d | %3d |\n", i, i*Base);
}
fprintf(Fp1, "--------------------\n");
}