-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSingleFileIO.cpp
More file actions
39 lines (25 loc) · 848 Bytes
/
SingleFileIO.cpp
File metadata and controls
39 lines (25 loc) · 848 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
// cpp program - working with a single file
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ofstream outf("ITEM"); //connect the item file to outf
cout << "Enter the item name" << endl;
char name[30];
cin >> name;
outf << name << endl; //write to file item
cout << "Enter the item cost" << endl;
float cost;
cin >> cost;
outf << cost << "\n";
outf.close(); //Disconnect the item file from the outf
// ifstream inf("ITEM"); //Connect the item file to inf
// inf >> name;
// inf >> cost;
// cout << endl;
// cout << "Item name : " << name << endl;
// cout << "Item cost : " << cost << endl;
// inf.close(); //Disconnect item from the inf
return 0;
}