Skip to content

Commit 40bf6a4

Browse files
add comment for reading binary file
1 parent 2ca4289 commit 40bf6a4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

file_read_all.cpp renamed to file_read_all(binary).cpp

+10
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,20 @@
77

88
int main(){
99
std::ifstream in("xxx.txt");
10+
11+
// this only works if there is no whitespace
12+
// in >> content;
1013

1114
// Method 1
1215
std::string content1((std::istreambuf_iterator<char>(in)),
1316
std::istreambuf_iterator<char>());
17+
18+
/**
19+
same as
20+
std::string content1;
21+
content1.assign((std::istreambuf_iterator<char>(in)),
22+
std::istreambuf_iterator<char>());
23+
**/
1424

1525
// Method 2
1626
std::stringstream ss;

0 commit comments

Comments
 (0)