Programs on File Handling
9
PROGRAMS ON FILE HANDLING: 1.Write a c++ program to accept a file and determine its size in bytes. #include<iostream.h> #include<conio.h> #include<fstream.h> #include<stdio.h> void main() { clrscr(); char cont[100]; ofstream fout("arnab.txt",ios::out); cout<<"\nenter contents of file\n"; gets(cont); fout<<cont; fout.close(); int nbytes=0; char ch; ifstream fin("arnab.txt"); while(!fin.eof()) { if(fin.get(ch)) nbytes++; } cout<<"FILE SIZE-"<<nbytes<<"bytes"; fin.close(); }
-
Upload
arnab-chakrabarti -
Category
Documents
-
view
216 -
download
0
description
file handling class 12
Transcript of Programs on File Handling
PROGRAMS ON FILE HANDLING:1.Write a c++ program to accept a file and determine its size in bytes.
#include#include#include#includevoid main(){clrscr();char cont[100];ofstream fout("arnab.txt",ios::out);cout