[SOLVED] CS #include

$25

File Name: CS_#include.zip
File Size: 103.62 KB

5/5 - (1 vote)

#include
#include
using namespace std;

int main()
{
ofstream output;
// Create/open a file
output.open(scores.txt);
// Write two lines
output << “John” << ” ” << “T” << ” ” << “Smith” << ” ” << 90 << endl;output << “Eric” << ” ” << “K” << ” ” << “Jones” << ” ” << 85 << endl;// Close the fileoutput.close();cout << “Done” << endl;string firstName, lastName; char mi; int score;// open file in read modeifstream input(“scores.txt”);// Read lineinput >> firstName >> mi >> lastName >> score;
// until file is empty: print line, then read other line
while (!input.eof()) {
cout << firstName << ” ” << mi << ” ” << lastName << ” ” << score << endl;input >> firstName >> mi >> lastName >> score;
}
input.close();
cout << “Done” << endl;return 0;}

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS #include
$25