Monday, October 15, 2012

C++ Program that displays the size of a file in bytes


 //Program that displays the size of a file in bytes
#include<iostream.h>
#include<conio.h>
int main()
{char filename[13];
cout<<"Enter File Name\n";
cin.getline(filename,13)
ifstream infile(filename,ios::in|ios::ate);
if(! infile)
{cout<<"Sorry.! cannot open"<<filename<<"file\n";exit(-1);}
long bytes=infile.tellg();
cout<<"File Size Is"<<bytes<<"bytes\n";
return 0;
}

No comments:

Post a Comment