Program to use fprintf() and getc()
#include<stdio.h>
main()
{
int n,i;
printf("\nEnter to print table (maximum) range :");
scanf("%d",&n);
FILE *table;
//will print the table in file named table.txt
table=fopen("table.txt","w");
for(i=0;i<=n;i++)
fprintf(table,"%d\n",i);
fclose(table);
//will print the table on screen
table=fopen("table.txt","r");
char c;
while((c=getc(table))!=EOF)
printf("%c",c);
fclose(table);
getch();
}
Comments
Post a Comment