Sunday, March 20, 2022

tarun using files

 #include <iostream>

#include <fstream>
using namespace std;
int main()
{
    ofstream myfile;
    myfile.open("filepointer.txt");
    myfile << "HELLO PAJI";
    cout << "CURRENT POSITION OF THE POINTER IS : " << myfile.tellp() << endl; // TELLS THE CURRENT POSITION OF THE POINTER (CURSOR)
    myfile.seekp(10, ios::beg);                                                // FIRSTLY beg POINTS TO THE BEGINING OF THE FILE AND THEN
                                                                               // POINTS TO THE 10TH POSITION OF THE FILE AND WRITES THERE
    cout << "CURRENT POSITION OF THE POINTER IS : " << myfile.tellp() << endl;
    myfile << "WORLD";

    myfile.close();
    char ch;
    ifstream my;
    my.open("filepointer.txt");

    cout << "CURRENT POSITION OF THE POINTER IS : " << my.tellg() << endl;
    my.seekg(5, ios::beg); // 5 se aage ka print hoga
    cout << "CURRENT POSITION OF THE POINTER IS : " << my.tellg() << endl;
    while (!my.eof())
    {
        my.get(ch);
        cout << ch;
    }

    return 0;
}

No comments:

Software scope

 In software engineering, the software scope refers to the boundaries and limitations of a software project. It defines what the software wi...

Popular Posts