Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

I need this C++ code converted to C code #include #include #include using namespace std; char *readableTime(long int sec) { // Converts seconds to time

I need this C++ code converted to C code

#include #include #include

using namespace std;

char *readableTime(long int sec) { // Converts seconds to time format time_t epoch_time = (time_t)sec;// Convert to character format return asctime(localtime(&epoch_time)); }

void readFile() { ifstream rFile1, rFile2; rFile1.open("Data1_in.txt"); rFile2.open("Data1_out.txt"); string data1, data2; long int time1, time2; string message1, message2; string phoneNo1, phoneNo2; rFile1>>time1; rFile2>>time2; rFile1>>phoneNo1; rFile2>>phoneNo2; data1 = readableTime(time1); data2 = readableTime(time2); getline(rFile1, message1); getline(rFile2, message2);

while(!rFile1.eof() && !rFile2.eof()){ if(data1.compare(data2) < 0) { cout<<" "<>time1; rFile1>>phoneNo1; data1 = readableTime(time1); getline(rFile1, message1); }

else {

cout<<" "<>time2; rFile2>>phoneNo2; data2 = readableTime(time2); getline(rFile2, message2); } }

while(!rFile1.eof()){ cout<<" "<>time1; rFile1>>phoneNo1; data1 = readableTime(time1); getline(rFile1, message1); }

while(!rFile2.eof()) { cout<<" "<>time2; rFile2>>phoneNo2; data2 = readableTime(time2); getline(rFile2, message2);} rFile1.close(); rFile2.close(); }

int main(){ readFile(); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions