Download presentation
Presentation is loading. Please wait.
1
Sequential input and output Operations in file
for(int i=0; i<len ; i++) { file.put(string[i]); } file,seek(0); // goto start char ch; while(file) file.get(ch); cout << ch; put() function is used to write a single character to the associated stream . get() function is used to read a single character from the associated stream. #include<iostream.h> #include<fstream.h> #include<string.h> void main() { char string[80]; cout << “Enter a string:”; cin >> string; int len=strlen(string); fstream file; file.open(“Data”.text”, ios::in | ios :: out); // opening the file for input and output
2
Reading and writing a class object
One of the major shorting coming of I/O system of c is that it can not handle the user define data types such as class objects . But class objects are the central elements of the C++ programming . The read() and write() binary functions are designed to do so These function can handle the entire structure of the object as a single unit.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.