143k views
5 votes
Write an application that displays the sizes of the files lyric1.txt and lyric2.txt in bytes as well as the ratio of their sizes to each other.

User Alexus
by
4.9k points

1 Answer

3 votes

Answer:

#include<iostream>

#include<fstream>

using namespace std;

int main() {

ifstream file_one("lyric1.txt", ios::binary);

ifstream file_two("lyric2.txt", ios::binary);

file_one.seekg(0, ios::end); // retrieving file size of lyric1.txt file

file_two.seekg(0, ios::end); // retrieving file size of lyric2.txt file

// converting the binary file size to an integer.

int fileOne = file_one.tellg();

int fileTwo = file_two.tellg();

cout<<"Size of the lyric1.txt is"<<" "<< fileOne<<" "<<"bytes";

cout<<"Size of the lyric2.txt is"<<" "<< fileTwo<<" "<<"bytes";

cout<< fileOne <<" : "<< fileTwo;

Step-by-step explanation:

The source code gets the file size of two word files and displays them in bytes and also displays the ratio of both files.

User Joomler
by
5.1k points