Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 02 / README.md
diff options
context:
space:
mode:
Commit1600ff61592b3fd94fb9029531fe35c0ed82cdf7 (patch)
Author
 Angel Dimitriev <achi_d@abv.bg>
2021-03-11 15:12:22 -0500
Committer
 GitHub <noreply@github.com>
2021-03-11 15:12:22 -0500
Files9c0bafb735e60f29da7acc7040cb4e772c74ad64 /Sem. 02/README.md
Object-oriented_programming_FMI-1600ff61592b3fd94fb9029531fe35c0ed82cdf7.tar
Object-oriented_programming_FMI-1600ff61592b3fd94fb9029531fe35c0ed82cdf7.tar.gz
Object-oriented_programming_FMI-1600ff61592b3fd94fb9029531fe35c0ed82cdf7.zip
Parentfdf055fa1d69aead38a28c7a3d155c9008a29963 (diff)
Update README.md
1 files changed, 27 insertions, 0 deletions
-rw-r--r--Sem. 02/README.md27
diff --git a/Sem. 02/README.md b/Sem. 02/README.md
index 2fcc1f7..bf6ca9a 100644
--- a/Sem. 02/README.md
+++ b/Sem. 02/README.md
@@ -54,6 +54,33 @@ int main()
file.close();
}
```
+Пример за прочитане на цялото съдържание файл:
+ ```c++
+#include <iostream>
+#include <fstream>
+using namespace std;
+
+const int BUFF_SIZE = 1024;
+int main()
+{
+ ifstream file("myFile.txt");
+
+ if (!file.is_open())
+ {
+ cout << "Error!" << endl;
+ return -1;
+ }
+ while (!file.eof())
+ {
+ char buff[BUFF_SIZE];
+ file.getline(buff, BUFF_SIZE);
+
+ //do something with the line
+ cout << line << endl;
+ }
+ file.close();
+}
+```
### Работа с поток за изход към файл (ofstream)
```c++