-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfileops.cpp
More file actions
43 lines (27 loc) · 694 Bytes
/
fileops.cpp
File metadata and controls
43 lines (27 loc) · 694 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
41
42
43
#include <fstream>
#include <iostream>
using namespace std;
int main() {
size_t size = 16 * 1024 * 1024;
const char* bitmap = "00100010101010010101010101010110010101100101101001101010010101101001101001010110";
std::string os_path("/home/md/1_1_10.bt");
std::ifstream fs(os_path, ios::in);
if (fs.good())
cout << "file exists" << std::endl;
else
cout << "file doesn't exists" << std::endl;
return 0;
//dump bitmap into file
std::ofstream ofs;
ofs.open(os_path);
ofs << bitmap;
ofs.close();
//read bitmap from file into string
std::ifstream ifs(os_path, ios::in);
std::string bt;
ifs >> bt;
cout << bt << endl;
cout << bt.size() << endl;
ifs.close();
return 0;
}