USE C DONT USE STRUC OR VECTOR Write a program to read the i

USE C++. DONT USE STRUC OR VECTOR.

Write a program to read the input file, shown below and write out the output file shown below. Use only string objects and string functions to process the data. Do not use c-string functions or stringstream (or istringstream or ostringstream) class object for your solution.

Input File

Output File

Cincinnati 27, Buffalo 24
Detroit 31, Cleveland 17
Kansas City 24, Oakland 7
Carolina 35, Minnesota 10
Pittsburgh 19, NY Jets 6
Philadelphia 31, Tampa Bay 20
Green Bay 19, Baltimore 17
St. Louis 38, Houston 13
Denver 35, Jacksonville 19
Seattle 20, Tennessee 13
New England 30, New Orleans 27
San Francisco 32, Arizona 20
Dallas 31, Washington 16

Solution

#include <iostream>
#include <fstream>
using namespace std;

// function definition, to open file for reading...
void openinfile(ifstream &infile)
{
char filename[100];
cout<<\"Enter the file name: \";
// Enter the filename that you have created
// (can include path). From the comment above
// you have to enter \"C:\\sampleread.txt\" without the double quotes.

cin>>filename;
infile.open(filename);
}

void main(void)
{
// declare the input file stream
ifstream inputfile;
// declare the output file stream
ofstream outputfile;

char chs;

// function call for opening file for reading...
openinfile(inputfile);
// create, if not exist and open it for writing
outputfile.open(\"C:\\\\samplewrite.txt\");

// test until the end of file
while (!inputfile.eof())
{
// read character until end of file
inputfile.get(chs);
if (!inputfile.eof())
{
// output character by character (byte) on screen, standard output
cout<<chs;
// write to output file, samplewrite.txt
outputfile<<chs;
}
}
cout<<\"\ Reading and writing file is completed!\"<<endl;
// close the input file stream
inputfile.close();
// close the output file stream
outputfile.close();
}

USE C++. DONT USE STRUC OR VECTOR. Write a program to read the input file, shown below and write out the output file shown below. Use only string objects and st
USE C++. DONT USE STRUC OR VECTOR. Write a program to read the input file, shown below and write out the output file shown below. Use only string objects and st

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site