-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleFileIODEMO.cpp
More file actions
42 lines (33 loc) · 1 KB
/
Copy pathSimpleFileIODEMO.cpp
File metadata and controls
42 lines (33 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//************************************************************************
// Author: Rolando Carreon
// Date: feb 18 2025
// Language: C++
// Assignment: SimpleFileIO DEMO
// Description: open a file and write a quote in itm then read the file
//************************************************************************
#include<iostream>
// include this for file saving and writing
#include<fstream>
using namespace std;
int main()
{
// declare local variables //
string myText;
ofstream myFile("testFile.txt");
// write to the file
myFile << "Quality is never an accident; it is always the result of "
<< "intelligent efforts. \n";
myFile << "\t --- Quote by William Forester --- ";
// close the file
myFile.close();
// open the file to read
ifstream myReadFile("testFile.txt");
//read the file and display the text
while( getline(myReadFile, myText) )
{
cout << myText << endl;
}
//close the file
myReadFile.close();
return 0;
}