-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathex40.cpp
More file actions
40 lines (31 loc) · 773 Bytes
/
ex40.cpp
File metadata and controls
40 lines (31 loc) · 773 Bytes
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
/*
CPSC 121-0X
Paul De Palma
depalma
Example 40
*/
//Writing using <<
#include <iostream>
#include <fstream> //data types used in file processing
using namespace std;
const int MAX = 81;
int main()
{
char line[MAX];
int howMany;
ofstream outputFile; //declare an output file object
outputFile.open("ex40.txt"); //associate the object with a file name
cout << "How many lines do you want to enter" << endl;
cin >> howMany;
cin.clear();
cin.ignore();
for (int i = 0; i < howMany; i++)
{
cout << "Enter line " << i + 1 << endl;
cin.getline(line,MAX - 1,'\n');
outputFile << line << endl;
}
outputFile.close(); //tell the O/S that it's OK to write the output buffer
//to the associated file.
return 0;
}