101
{ USER }
posts: 55
last: 09-Apr-2008
TITLE: Program to find number of Bytes in a text file
DESCRIPTION: Program to find number of Bytes in a text file
Submitted: 09-Apr-2008 11:06:39 ( 32w 0d 7h ago ) Language: C++ (*.cpp *.h)
Views: 200 Lines of Code: 50 LINES
Rating:
rate: star1
star2
star3
star4
star5
dstar1
dstar2
dstar3
dstar4
dstar5  ( rated! )
  { 0.00 / 5 }
Difficulty: Intermediate
Bookmark
/* Author: 101
   Date: 09-04-2008
   Filename: 
   Description: Program to find no. of Bytes in a text file
   History: 
*/


#include<fstream.h>
#include<process.h>
#include<stdio.h>
#include<iostream.h>
#include<process.h>
#include<conio.h>
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<<ch;
 }
 }
 cout<<"

Total no. of Bytes are  "<<c;
 f1.close();
 cout<<"

Press Enter key to continue...";
 getch();
 return(0);
}