Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- /**
- * Funkcja ignoruje napotkane białe znaki w strumieniu
- * zwraca liczbę usuniętych znaków z strumienia
- */
- int ignoreWhiteMarks(istream& in) {
- int howMany = 0;
- while (in.peek() == 10 || in.peek() == 32)
- in.ignore();
- return howMany;
- }
- int main() {
- int value;
- char what;
- string str;
- filebuf* fb = new filebuf();
- fb->open("plik.tmp", ios::in);
- istream plik(fb);
- while (!plik.eof()) {
- ignoreWhiteMarks(plik);
- what = plik.peek(); //podglądamy co jest w strumieniu
- if (isdigit(what)) {
- plik>> value;
- cout <<"Liczba: " <<value <<endl;
- } else {
- plik>> str;
- cout <<"Nie liczba: " <<str <<";" <<endl;
- }
- }
- fb->close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement