This document discusses file operations in C++. It defines what a file is and the different types of files. It describes the different file stream classes - ofstream for output, ifstream for input, and fstream for both. It covers opening and closing files, different file modes, and stream state member functions. It also provides examples of reading and writing characters to files using get() and put().
Text Input / Output: Files, Streams, Standard Library Input / Output Functions, Formatting Input / Output Functions, Character Input / Output Functions, Binary Input / Output: Text versus Binary Streams, Standard Library, Functions for Files, Converting File Type
Text Input / Output: Files, Streams, Standard Library Input / Output Functions, Formatting Input / Output Functions, Character Input / Output Functions, Binary Input / Output: Text versus Binary Streams, Standard Library, Functions for Files, Converting File Type
Contents:-
Introduction
What is a File?
High Level I/O Functions
Defining & Opening a File
Closing a File
The getc and putc Functions
The getw and putw Functions
The fprintf and fscanf Functions
C Programming Language is the most popular computer language and most used programming language till now. It is very simple and elegant language. This lecture series will give you basic concepts of structured programming language with C.
Textbook Solutions refer https://pythonxiisolutions.blogspot.com/
Practical's Solutions refer https://prippython12.blogspot.com/
Computer program works with files. This is because files help in storing information permanently. A file is a bunch of bytes stored on some secondary storage devices.
Contents:-
Introduction
What is a File?
High Level I/O Functions
Defining & Opening a File
Closing a File
The getc and putc Functions
The getw and putw Functions
The fprintf and fscanf Functions
C Programming Language is the most popular computer language and most used programming language till now. It is very simple and elegant language. This lecture series will give you basic concepts of structured programming language with C.
Textbook Solutions refer https://pythonxiisolutions.blogspot.com/
Practical's Solutions refer https://prippython12.blogspot.com/
Computer program works with files. This is because files help in storing information permanently. A file is a bunch of bytes stored on some secondary storage devices.
Brief PPT on File Handling Operations which includes opening, closing, writing, reading of the file. The program done in this is worked on DEV C++. but i advice the viewers and the students who wants to take the idea then please do practice your and your own program as an example so that you will understand the topic very well.
Python too supports file handling and allows users to handle files i.e., to read and write files, along with many other file handling options, to operate on files. The concept of file handling has stretched over various other languages, but the implementation is either complicated or lengthy, but alike other concepts of Python, this concept here is also easy and short. Python treats file differently as text or binary and this is important. Each line of code includes a sequence of characters and they form text file. Each line of a file is terminated with a special character, called the EOL or End of Line characters like comma {,} or newline character. It ends the current line and tells the interpreter a new one has begun. Let’s start with Reading and Writing files.
Ethnobotany and Ethnopharmacology:
Ethnobotany in herbal drug evaluation,
Impact of Ethnobotany in traditional medicine,
New development in herbals,
Bio-prospecting tools for drug discovery,
Role of Ethnopharmacology in drug evaluation,
Reverse Pharmacology.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
This is a presentation by Dada Robert in a Your Skill Boost masterclass organised by the Excellence Foundation for South Sudan (EFSS) on Saturday, the 25th and Sunday, the 26th of May 2024.
He discussed the concept of quality improvement, emphasizing its applicability to various aspects of life, including personal, project, and program improvements. He defined quality as doing the right thing at the right time in the right way to achieve the best possible results and discussed the concept of the "gap" between what we know and what we do, and how this gap represents the areas we need to improve. He explained the scientific approach to quality improvement, which involves systematic performance analysis, testing and learning, and implementing change ideas. He also highlighted the importance of client focus and a team approach to quality improvement.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
How to Split Bills in the Odoo 17 POS ModuleCeline George
Bills have a main role in point of sale procedure. It will help to track sales, handling payments and giving receipts to customers. Bill splitting also has an important role in POS. For example, If some friends come together for dinner and if they want to divide the bill then it is possible by POS bill splitting. This slide will show how to split bills in odoo 17 POS.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
2. What is a file..?
File Streams
File operations
Opening of a file
Closing of a file
File Modes
Stream State Member Functions
Reading/Writing a Character from a
file
Data File operations
3. What is file..?
File is a collection of data or a set of characters or may be
a text or a program.
Types of files
i) Sequential files.
ii) Random access files.
Data File operations
4. File Streams
ofstream
This data type represents the output file
stream and is used to create files and to write
information to files.
ifstream
This data type represents the input file stream
and is used to read information from files.
fstream
This data type represents the file stream generally,
and has the capabilities of both ofstream and ifstream
which means it can create files, write information to
files, and read information from files.
Data File operations
5. Header file used for file operations
fstream.h
Data File operations
6. OPENING AND CLOSING OF FILES
Opening a File.
i) ifstream – To read a stream of objects from a file.
eg:
#include<fstream.h>
void main()
{
ifstream infile; // creating class object
infile.open(“data_file”); // opening a file
……………………………
}
Data File operations
7. ii) ofstream – To write a stream of objects on a file.
eg:
#include<fstream.h>
void main()
{
ofstream infile; // creating class object
infile.open(“data_file”); // opening a file
……………………………
}
Data File operations
8. ii) fstream – Both read and write.
eg:
#include<fstream.h>
void main()
{
fstream infile; // creating class object
infile.open(“data_file”, ios::in|| ios::out // opening a file
……………………………
}
Data File operations
9. Name of the member function Meaning
ios :: in Open a file for reading
ios :: out Open a file for writing
ios :: app Append at the end of a file
ios :: ate Seek to the end of a file upon opening
Instead of beginning
ios :: trunc Delete a file if it exists and recreate it
ios :: nocreate Open a file if a file does not exist
ios :: replace Open a file if a file does exist
Data File operations
ios :: binary Open a file for binary mode; default is
text
File Modes
10. Closing a File
Using the function close(); with no arguments.
eg:
#include<fstream.h>
void main()
{
ofstream infile;
infile.open(“data_file”);
……
infile.close(); // calling to close the file
}
Data File operations
11. STREAM STATE MEMBER FUNCTIONS
Information status of file.
Returns a Binary value
i) eof() – check whether the file pointer has reached the end
of file or not.
eg:
#include<fstream.h>
void main()
{
ifstream infile;
infile.open(“text”);
while(!infile.eof())
{……………………………..}
}
Data File operations
12. ii) fail()– check whether the file has been opened for i/o
successfully
eg:
#include<fstream.h>
void main()
{
ifstream infile;
infile.open(“text”);
while(!infile.fail())
{ cout<<“Couldn’t open a file”;
……………………………..}
}
Data File operations
14. iv) good()– check whether the previous file operation
has been successful or not..
eg:
#include<fstream.h>
void main()
{
ifstream infile;
infile.open(“text”);
if(infile.good())
{
……………………………..}
}
Data File operations
15. Reading/Writing A Character
From A File
i) get()– Used to read an alphanumeric character from a
file.
eg:
#include<fstream.h>
void main()
{
ifstream infile;
char ch;
infile.open(“text”);
while(!infile.eof())
{
ch=infile.get();
……………….
}
Data File operations
16. #include<fstream.h>
#include<conio.h>
void main()
{
ifstream fin;
char ch;
fin.open("demo.txt");
cout<<"nData in file...";
while(!fin.eof())
{
fin.get(ch); // get character
cout<<ch; // display a character onto screen
}
fin.close();
}
Output :
Data in file... Hello friends, my name is arJun.
Data File operations
17. ii) put()– Used to write a character to a specified
file/output stream.
eg:
#include<fstream.h>
void main()
{
ofstream outfile;
char ch;
outfile.open(“text”);
while(!infile.eof())
{
ch=outfile.get();
cout.put(ch); // display a character onto screen
……………
}
Data File operations
18. #include<fstream.h
#include<conio.h>
void main()
{
ofstream fout;
char ch;
fout.open("demo.txt");
do
{
cin.get(ch); // get character
fout.put(ch); // writing to file
}while(ch!=EOF);
fout.close();
cout<<"nData written successfully...";
}
Output :
Hello friends, my name is kumar.
Data written successfully...
Data File operations