Advertisement
Guest User

task

a guest
Mar 19th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <stdio.h>
  4. #include <cmath>
  5. #include <fstream>
  6. using namespace std;
  7.  
  8.  
  9. int main()
  10. {
  11.     ofstream file("text.txt");
  12.     if(!file){
  13.         cout<<"Could not open the file.\n";
  14.         return 1;
  15.     }
  16.     file << "abcdefg"<<endl;
  17.     file.close();
  18.  
  19.  
  20.     ifstream ifile("text.txt");
  21.     if(!file){
  22.         cout<<"Could not open\n";
  23.         return 1;
  24.     }
  25.     cout<<"abcdefg"<<endl;
  26.     ifile.seekg(0,ios::beg);
  27.     cout<<ifile.tellg()<<endl;
  28.     char ch;
  29.     ifile >> ch;
  30.     cout<<ch<<" "<<ifile.tellg()<<endl;
  31.     ifile >> ch;
  32.     cout<<ch<<" "<<ifile.tellg()<<endl;
  33.     system("pause");
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement