Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream> // file stream
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- ifstream plik; // plik tylko do odczytu
- plik.open("plik.txt"); // otwarcie pliku
- if (plik.fail()) // .fail() zwraca true jeśli plik nie został otwarty
- {
- cout << "Nie udalo sie otworzyc pliku :( \n";
- return 0;
- }
- string tekst;
- //plik >> tekst; // pobranie do pierwszgo białego znaku (np. spacji)
- //while (!plik.eof()) // eof - end of file
- //{
- // plik >> tekst;
- // cout << tekst << ' ';
- //}
- /*while (plik >> tekst)
- {
- cout << tekst << ' ';
- }*/
- // zczytywanie całego wiersza:
- getline(plik, tekst);
- cout << tekst;
- plik.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement