#include<stdio.h>
#include<conio.h>
void main()
{
struct stud
{
int sno;
float per;
char name[20],add[20];
}s;
int i,n;
int size = 0;
char ch;
FILE *fp;
fp=fopen("a.txt","w");
if(fp==NULL)
{
printf("\nUnable to open file!");
}
else
{
printf("\nEnter the stud no:->");
scanf("%d",&s.sno);
printf("\nEnter the stud name:->");
scanf("%s",s.name);
fprintf(fp,"%d\n%s",s.sno,s.name);
}
fseek(fp, 0, 2); /* file pointer at the end of file */
size = ftell(fp); /* take a position of file pointer un size variable */
printf("The size of given file is : %d\n", size);
fclose(fp);
getch();
}
Output:
/