
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
tellp() in file handling with C++
In C++ file handling, the tellp() function is used with output streams, and returns the current put position of the pointer in the stream. It returns an integer data type, representing the current position of the stream pointer.
tellp() method takes no parameter. It is written as: pos_type tellp();
Algorithm
Begin. Create an object newfile against the class fstream. Call open() method to open a file “tpoint.txt” to perform write operation using object newfile. Insert data into the file object newfile. Call the tellp() method to print the present position of the pointer in the file object. Call close() method to close the file object. End.
Example
#include <iostream> #include <iostream> #include <fstream> using namespace std; int main() { fstream newfile; newfile.open("tpoint.txt", ios::out); //open a file to perform write operation using file object newfile << "Tutorials Point"; //inserting data cout << "The present position of the pointer in the file: " << newfile.tellp() << endl; //position of the pointer in the file object newfile.close(); //close file object. }
Output
The present position of the pointer in the file: 15
- Related Articles
- File Handling in C#
- Set position with seekg() in C++ language file handling
- Basics of File Handling in C
- File Handling through C++ Classes
- Basics of File Handling in C Programming
- How to configure handling and formatting of log file in Selenium with python?
- File Handling in Java using FileReader and FileWriter
- MySQL Command-Line Options that Affect Option-File Handling
- Handling Alerts with Cypress
- Handling Frames with Cypress
- PHP Exception Handling with finally
- Handling Child Tabs with Cypress
- Handling Web Tables with Cypress
- Handling Child Windows with Cypress
- Exception handling with method overriding in Java.

Advertisements