#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
FILE *fp;
char c,name[10];
long int size=0;
clrscr();
printf("Enter the file name with extension(like .txt,.c,.cpp):");
scanf("%s",name);
fp=fopen(name,"r");
if(fp==NULL)
{
printf("Unable to open the file");
getch();
exit(5);
}
while((fscanf(fp,"%c",&c))!=EOF)
size++;
printf("Size of file: %ld bytes",size);
getch();
}
No comments:
Post a Comment