Showing posts with label command line argument. Show all posts
Showing posts with label command line argument. Show all posts

26.8.15

Write a C++ program that displays the size

Write a C++ program that displays the size (in bytes) of a given file. The name of

the file is specified as command line argument.

#include<iostream.h>

#include<fstream.h>

#include<conio.h>

void main(int arge,char*argv[])

{

int bcount=0; char cl; ifstream testfile; clrscr();

cout<<"enter the file name\n"; cin>>argv[1]; testfile.open(argv[1],ios::in); while(testfile)
{

testfile.read((char*)&cl,sizeof(cl));

++bcount;

}

testfile.close();

cout<<"size of the given file:"<<argv[1]<<"is"<<bcount<<"bytes"<<endl; getch();
}


*********************************OUTPUT********************************


enter the file name

ph.cpp


size of the given file:is2308bytes