CPP Program For Find Size Of File and Also Display Content Of File Using File Stream
#include
#include
#include
#include
#include
#include
main()
{
clrscr();
int c=0;
char ch,file[30];
cout<<"Enter the name of the file:";
gets(file);
fstream f1;
f1.open(file,ios::in);
if(f1.bad())
{
cout<<"File can not be opened.";
exit(0);
}
if(f1.good())
{
cout<<"The current contents of the file are:";
while(f1)
{
f1.get(ch);
c++;
cout<
Sample Output :
Enter the name of the file:ex.c
The current contents of the file are:#include<stdio.h>
void main()
{
int i;
printf("%d",i);
} Total no. of Bytes are 61Press Enter key to continue...