Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include <cstring>
- #include <cmath>
- #include <fstream>
- using namespace std;
- int _tmain(int argc, _TCHAR* argv[])
- {
- ifstream inFile;
- ofstream outFile;
- //inFile.open("plates.txt"); FOR IFSTREAM: ([file name], [access mode (ios::read, ios::write, ios::app)]) ios::app adds data onto file, without it, the file will be overwritten
- outFile.open("plates.txt", ios::app);
- string number;
- string reading;
- do
- {
- cout << "Enter a license plate number: ";
- cin >> number;
- if (number != "0")
- {
- outFile << number << endl;
- }
- }
- while (number != "0"); //Use "" double quotations when working with cstrings
- outFile.close();
- inFile.open("plates.txt");
- if (!inFile)
- {
- cout << "Error opening file!" << endl;
- }
- cout << "\nYou entered the following license plate numbers:" << endl;
- while (!inFile.eof())
- {
- inFile >> reading;
- cout << reading << endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement