#include <iostream>
#include <stdio.h>
#include <fstream>
#include <string>
using namespace std;
int main()
{
int number_Of_Lines_To_Print_From_End=0;
char file_name[20];
streampos length;
cout<<"enter file name that needs to be opened\n";
cin>>file_name;
cout<<"enter number of lines to print from end of file\n";
cin>>number_Of_Lines_To_Print_From_End;
fstream file;
file.open(file_name, ios::out );
if(file.is_open())
{
cout<<"the file opened\n";
}
else
{
cout<<"the file didn't open\n";
}
file.seekg(0,ios::end);
length=file.tellg();
file.seekg(0,ios::beg);
cout<<"the length is"<<length<<"\n";
return 0;
}
lotrsimp12345 37 Posting Pro in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.